6 Replies Latest reply on Feb 25, 2014 5:18 AM by mcollinge

    Content macro with dynamic content


      We have a requirement to have a content macro that will display different data based on the user's country. So it might be a Document has an introduction that shows one thing for France, and another thing for the UK. The problem is that once a macro runs, it puts the result into a memory cache, and in a table (jiveRenderedContent).


      Is there a simple directive that tells Jive to always render a certain macro when a page is viewed, using the cache for everything but that macro?


      (I'm pretty sure this won't be possible, but I'd like to rule it out before we go down the icky JavaScript route to conditionally display stuff after page render ).





        • Re: Content macro with dynamic content
          Ryan Rutan

          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,



            • Re: Content macro with dynamic content

              Brilliant, thanks Ryan, I'll take a look and get it prototyped in my local environment.


              Use cases;


              - 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.

              • Re: Re: Content macro with dynamic content

                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?



                  • Re: Content macro with dynamic content

                    Hi Guys,


                    cc: Ryan Rutan, Matt Collinge


                    Have the same caching issue.. Would be incredibly interesting how to stop caching inside jiveRenderedConetnt without reinventing bicycle.

                    Let me please know if somebody figured out how to resolve that.


                    Thanks, Dzmitry

                    • Re: Content macro with dynamic content
                      Ryan Rutan

                      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 :/

                        • Re: Content macro with dynamic content

                          We ended up implementing this using JavaScript which can be interpreted at runtime. So our feature required us to display certain pieces of content for certain countries, so we've put in a RTE dialog that generates script like this;


                          <p><span class="e14-init-hidden e14-conditional-content" data-e14-conditional-country="UK,FR">Hello UK and France</span></p>


                          We already have other JavaScript running on page load, so we extended that to look for span's with a class of e14-conditional-content and show them according to the countries in the data attribute.


                          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.