I want to hook into the rendering of a content node. Let's say I have a string in the bodyText of a node. [mystring]. When this renders I would like to replace that string with something else.
I've been looking att the BeforeUpdateDocumentCache-event but that would only allow me to change the document and I don't want my change to be permanent. Just only for this request. (or only in the node cache could work).
Hi! Yes i know about the events but I can't really find a hook that would do the job. I don't want to do the processing in a macro (like the razor example). I want it to either store the replace in the cache or perfom it at each request.
Well that was just an example and I did everything in Razor so people would understand it better. In the situation where I needed this it was done in a static class which did everything I needed. You would still need to call it in Razor, but in a much cleaner way. Something like this:
//getting the node normal dynamic currentNode = Modal;
//getting the node with modified data for this 1 request dynamic currentNode = ProjectHelper.GetUpdatedNode();
Maybe you can give your template a code behind and change the Modal in it's page load (didn't test if this is possible). If you do that make sure that the razor will be rendered on pre render so what you've done in the page load is available there.
Hi. I think that in scenario you have described you could just create a macro that will do all the job and that's allowed to be used inside RTE and insert it in your bodyText.
The thing is that this is suppose to be a part of a package where the content nodes will contain stuff in the bodyText (RTE) that should be replaced when the node is rendered as content on the site. But when it's used though the API the orginal values should be there. I guess a macro could do the work but I'm looking for a solution thats more "buildt in under the hood". Like if there was en event that fired when a page was rendered:
Hook into the rendering
Hi!
I want to hook into the rendering of a content node. Let's say I have a string in the bodyText of a node. [mystring]. When this renders I would like to replace that string with something else.
I've been looking att the BeforeUpdateDocumentCache-event but that would only allow me to change the document and I don't want my change to be permanent. Just only for this request. (or only in the node cache could work).
Have a look at this blog to see if there's an event you can use: http://www.richardsoeteman.net/2009/02/22/UmbracoV4EventsDemo.aspx.
If it's only for one request this wiki might also be interessting: http://our.umbraco.org/wiki/reference/code-snippets/add-fake-property-to-a-content-node. There you add a "temp/fake" property to a content node for only 1 request. You could also get an existing property and update that for 1 request in this way.
Jeroen
Hi!
Yes i know about the events but I can't really find a hook that would do the job. I don't want to do the processing in a macro (like the razor example). I want it to either store the replace in the cache or perfom it at each request.
Well that was just an example and I did everything in Razor so people would understand it better. In the situation where I needed this it was done in a static class which did everything I needed. You would still need to call it in Razor, but in a much cleaner way. Something like this:
Maybe you can give your template a code behind and change the Modal in it's page load (didn't test if this is possible). If you do that make sure that the razor will be rendered on pre render so what you've done in the page load is available there.
Jeroen
Hi. I think that in scenario you have described you could just create a macro that will do all the job and that's allowed to be used inside RTE and insert it in your bodyText.
Hi Markus,
Check out my Shortcodes package. (I'm replying from my mobile, and can't paste the link... Just search for it)
Cheers, Lee.
Hi!
The thing is that this is suppose to be a part of a package where the content nodes will contain stuff in the bodyText (RTE) that should be replaced when the node is rendered as content on the site. But when it's used though the API the orginal values should be there. I guess a macro could do the work but I'm looking for a solution thats more "buildt in under the hood". Like if there was en event that fired when a page was rendered:
If(loadedNode.Type = "yada")
{
// Replace stuff
}
@Lee - Awesome! Thats what I'm looking for! When dose the "replace" happen? On each request? Or when the cache is updated? Link: http://our.umbraco.org/projects/developer-tools/shortcodes
The replacement happens in a Response.Filter, registered in a HttpModule. The source is up on my BitBucket, feel free to extract what you need.
Nice stuff. It's a possible solution that I've already thought of as well. It's great that there's a ready-to-use module for it.
@Lee - Great! This is what I was searching for. Many thanks!
is working on a reply...