Forum Discussion

dustin's avatar
dustin
Expert
8 years ago

How to detect search context (forums vs tkb) on SearchPage

On the SearchPage, I would like to change the styling based on if users are searching the forums or knowledge base, or users.

I see that within the url, this information exists.

t5/forums/searchpage/tab/tkb?location=community%3Azjzhh79394

Is there a way to access this via freemarker?

  • dustin - Yes, you could use this context object and then code your way through.

     

    http.request.urlReturns the full request URL including protocol, server name, path, and query string parameters9.5.1
     ${http.request.url}

     

    Source

     

    I hope this helps.

  • dustin - Yes, you could use this context object and then code your way through.

     

    http.request.urlReturns the full request URL including protocol, server name, path, and query string parameters9.5.1
     ${http.request.url}

     

    Source

     

    I hope this helps.

    • dustin's avatar
      dustin
      Expert

      Following the recommendation, here is the code I ended up with...

       

      <#if page.name == 'SearchPage' && http.request.url?index_of('tkb')?number gt 0>
      // Knowledge Base tab on Search Page is selected
      </#if>