I have a use case where a component is rendered via js within an ftl component. I’m running into an issue where, after the author makes a change to a component, the channel view isn’t updated until the page is refreshed. Is there any way to trigger a refresh in the channel after a component has been updated?
I haven’t tried it yet and not sure ;-), but it will probably refresh the page if your component adds a new head contribution  in preview mode.
For example, if you have a FTL template containing the JS, you might want to try something like this:
Would you give it a try?
I tried to implement the head contribution, and it is not working for me. The issue could be because the js is not included at the component level. We have created a large global js file that is included on every page. Here’s the contents of my component ftl file:
And then I added the following line within my base-layout file (that is used on every page) in the element:
Is there anything I’m missing?
Could you try it with moving the
<#if hstRequestContext.channelManagerPreviewRequest> block above the
<#if document??> block and removing the
(<@hst.headContributions/> is unnecessary in each component template as it’s done in the root/base template.)
Pages are reloaded only if new head contributions are added:
see also example of component re-initializations in our carousel example:
It looks like you’re reloading the page with some jquery. Would you be able to link me to that jquery file?
actually process is a bit different in above case:
- You drop a carousel component which includes some head contributions
- HST detects it, and reloads the page: carousel is initialized with 0 items. All good.
- You change carousel and link/add an image to it. Now, HST will not reload the page because no head contributions are added/changed. Carousel component is still in its old state and “thinks” it has 0 items.
Now, only way to tell carousel component that we added an item is to either reload the page or trigger our script again to re-initialize carousel again. In above case we are doing the latter, by calling init method for carousel component:
Only other option would be to reload the page, or try what Woonsan suggested (I haven’t tried it myself).
Seems like we are facing the same problem. We are however running on BR v 13.4.2.
From which version onwards should the head contributions fix work? I have tried on an empty archetype project with the same version. I installed the banners feature and added a banner to my homepage.
When first adding a carousel to my page I can see the following in the html:
However the page does not reload so the contributions do not show up in my , and therefore the banner will not look fine and the interaction does not work. When the page is refreshed the banner looks and works fine.
Is this head contribution “fix” supposed to work on br 13.4.2?
Sorry I haven’t responded for so long, I have been pulled onto several other issues. But to add to what @lucaswiersma said, I also haven’t been able to get this fix to work on 14.3.3.
Can one of you guys possibly share your light on this?
My understanding was that the first time a component added to a page adds a head contribution the whole page should be re-rendered to make sure said head contribution is loaded. When the component changes the page is not reloaded because a trace had been kept of which head contributions where already loaded.
However even when I first add a new component that includes a head contribution my page is not fully re-rendered and I can see in the commented out section in the html that the head contribution is not processed. Should anything be configured to enable reloading the page fully when there are unprocessed head contributions?
I don’t know the detail how the channel manager works. I just replied based on some information like the following:
When a container or component is re-rendered, we check whether the new markup also contains unprocessed head contributions that are not part of the page yet. If so, we reload the page to make sure those head contributions are also loaded. 
My understanding is that the page should be reloaded if the component contributes an unprocessed - “new” head contribution item - to the page.
So, if you can try to contribute a new (randomly generated) head contribution in preview mode every time in rending, I expect the page including the component to be re-rendered.
Ok than at least our understandings are the same .
However in practise this does not seem to work that way for me. I checked this using a new install based on a 13.4.2 archetype and adding only the skeleton site and the banner type.
When rendering a carrousel without changeing anything to the code I would expect this carrousel to be rendered correctly because multiple head contributions are in the default code. So I would expect that the page would be re-rendered at least on first adding the component but this does not seem to be the case.
Can I do anything else to force a page reload after adding/updating a component to my page?