Forum Discussion

iftomkins's avatar
11 years ago

Test interaction style of current node

How do I test, via freemarker, what the interactions style of the page I'm on is?   I need to run some code when I'm at this URL:   https://community.stage.fitbit.com/t5/Help-Forums/ct-p/product/...
  • iftomkins's avatar
    iftomkins
    11 years ago

    Thanks, Adam! I tried the get parameter method but I think that will only return ?parameters=likeThese. Parsing the URL itself worked, here's the solution:

     

        <#assign currentUrl = http.request.url />
        <#if currentUrl?contains("idea")>
            <#--We know it's an ideas board-->
        </#if>

     

    This also helped solve the issue where the current node.Id returns "discussions" when you're looking at a list of ideas boards and when you're looking at a list of forums boards (i thought IDs were unique?). Now we can filter by whether the URL contains "interaction-style/idea":

     

        <#assign currentUrl = http.request.url />
        <#if coreNode.id=="feedback">
            ${http.response.setRedirectUrl("t5/Help-Forums/ct-p/product/interaction-style/idea")}
        <#elseif coreNode.id== "discussions" && currentUrl?contains("interaction-style/idea")>
            ${http.response.setRedirectUrl("t5/Help-Forums/ct-p/product/interaction-style/idea")}
        </#if> 

     

    For anyone coming across this post, just a reminder that all this code needs to be run in the Page Initialization tab. To get access to the Page Initialization tab you must contact Lithium Support.