Use a filter instead, they run conditionally on every load. That is how I have the ManagedSnippets working.
I’ll attach an example Filter for you to play around with from my old UncFilter/Plugin. UncLinkPlugin shows how to register a filter, and the other is the actual filter. Just make sure that your execution order is like 1000 or higher, that way it will run at the very end. If it runs mid-stack, there are chances of other filters undoing what you do.
Note: This concept is not supported in the cloud, and I'd recommend you strongly consider that fact before going too crazy with this capability. Would love to hear more about the use-case when you have a chance,
Brilliant, thanks Ryan, I'll take a look and get it prototyped in my local environment.
- We have different store websites for different locales; in a Community document where we talk about a particular product we might need to say something specific about that product which doesn't apply anywhere else.
- For some countries, they have more than one place to purchase a product (usually there's only 1 option), so we need a way to present that cleanly to the user
- Some content, like terms and conditions, might need to reflect country-specific rules & regulations clearly without lots of annotations saying ** In Germany, blah blah.
- We might want to swap out a brand name used in one region to read something else in another, e.g. US knows it as Axe, UK knows it as Lynx.
I've implemented a simple filter; it's running correctly once, and then caches the result so that every user sees the same thing. I tested this by adding a random number into the text that the filter alters.. each user should see something different.
The result of the filter is being saved into jiveRenderedContent. Is there something I've missed to stop this from happening?
content-filter.zip 8.5 KB
The one piece of detail that I left out was that your filter will have to render client side scripting that meshes in the dynamic artifacts on every view.. There is no way to bypass the caching of a document's rendering that I am aware of, and from a performance perspective your
don't want to.
In hind sight you could do this with a macro as well, this is future Ryan thinking past Ryan didn't fully read the original question. Sorry about that :/
<p><span class="e14-init-hidden e14-conditional-content" data-e14-conditional-country="UK,FR">Hello UK and France</span></p>
In spite of it being a bit clunky, one advantage of this is that the content is still indexed by Google. It also doesn't customise the core product, and doesn't hit problems with the content caches.