I have a requirement to intercept published content and manipulate a few different parts prior to their rendering on the front-end website. I've been trying to work with the BeforeContentControlLoad event. I've included the code below. This file is sitting in App_Code/Events/InterceptContent.cs. I can't seem to get the event to fire. Any ideas where I'm going wrong?
Thanks!
using umbraco.BusinessLogic;
using umbraco.cms.businesslogic.web;
using umbraco.controls;
namespace Umbraco.Extensions.app_code.Events
{
public class ParseContent : ApplicationBase
{
public ParseContent() {
ContentControl.BeforeContentControlLoad +=
new ContentControl.BeforeContentControlLoadEventHandler(Content_BeforeLoad);
}
public void Content_BeforeLoad(
ContentControl sender,
umbraco.controls.ContentControlLoadEventArgs e) {
I suspect that you will need to compile your extesion into a DLL as I think that Umbraco uses reflection to register events such as this at application start up.
So it's likely your event is never getting registered.
Thanks for the response Tim. I worded my original post poorly. I currently have the event handler in a supporting Umbraco.Extensions project that is bundled into a .dll and copied into the Umbraco/bin folder. The event should be able to be loaded through reflection without an issue.
Perhaps I do not understand when this event is fired. Is it on any document load on the front-end website? That is the event I'm looking for, but I'm not sure what a "ContentControl" is referring to exactly.
Content Interception
Greetings,
Umbraco 4.0.2.1
I have a requirement to intercept published content and manipulate a few different parts prior to their rendering on the front-end website. I've been trying to work with the BeforeContentControlLoad event. I've included the code below. This file is sitting in App_Code/Events/InterceptContent.cs. I can't seem to get the event to fire. Any ideas where I'm going wrong?
Thanks!
I suspect that you will need to compile your extesion into a DLL as I think that Umbraco uses reflection to register events such as this at application start up.
So it's likely your event is never getting registered.
Tim
Thanks for the response Tim. I worded my original post poorly. I currently have the event handler in a supporting Umbraco.Extensions project that is bundled into a .dll and copied into the Umbraco/bin folder. The event should be able to be loaded through reflection without an issue.
Perhaps I do not understand when this event is fired. Is it on any document load on the front-end website? That is the event I'm looking for, but I'm not sure what a "ContentControl" is referring to exactly.
Any insight is greatly appreciated!
Cheers,
--
Danny
Ahh right I see now.
The event you are firing is for the backend of Umbraco, when the content control is loaded into the editor.
For the front end I'm not aware of an event that would fit the bill.
If all you are trying to do is fiddle with some content that would normally be included in the template via a <umbraco:Item> tag you could:
Write a user control which grabbed the item via the Umbraco API and did the content change then rendered it to the page.
Write an XSLT macro which would do similar.
You could have some c# code on the template which on Page_Load looked for the <umbraco:Item> in question by ID and did some fiddling.
As I say it depends very much on what you are after.
Tim
Thanks for the post - that solution works!
Which one?
And don't forget to mark the post as solved!
Glad I could help.
Tim
is working on a reply...