Forum Discussion

Akenefick's avatar
Akenefick
Genius
3 years ago

Custom Page Context

If I create a custom page that I will link to from a component on the Idea Page for example, is there a way to pass the "context" of that idea page to the custom page so that components there will "k...
  • jeffshurtliff's avatar
    3 years ago

    There are a few different ways you could go about this.

    The first way is that you can definitely include /board-id/${coreNode.id} in the URL and then use the FreeMarker below to retrieve it on the custom page. (I do this in a few of my custom pages.)

    <#assign boardId = webuisupport.path.rawParameters.name.get('board-id', '') />

     

    A similar way would be to use a query string, such as ?boardId=${coreNode.id} in your URL, which would use the FreeMarker below to retrieve.

    <#assign boardId = http.request.parameters.name.get('boardId','') />

     

    The third way (if you didn't want to pass something in the URL for some reason) would be to use a session attribute, as shown below.

    <#-- Set the session attribute on the originating page -->
    ${http.session.setAttribute('boardId', coreNode.id)}
    
    <#-- Retrieve the session attribute value on the custom page -->
    <#assign boardId = http.session.attributes.name.get('boardId', '') />

     

    (The empty strings in all of the examples above represent the default/fallback value.)

    Hope this helps!