Forum Discussion

Inactive User's avatar
Inactive User
12 years ago

Getting tag from URL

We are trying to edit the TagViewPage and need to know which tag is currently being displayed with Freemarker. I tried every attribute or parameter call I could find but to no success.   Currently,...
  • AdamA's avatar
    12 years ago

    I think you're workaround is good, one thing you might consider changing is instead of relying on the length of the URL sections and the location of the tag-value section within the array, you could instead rely on the order. In the case of the TagViewPage the URL section representing the tag value will always be preceded by a URL section called "tag". The creates a key/value pair like this: /tag/<tag-value>. So the code might look something like this:

     

    <#assign urlSections = http.request.url?split("/") />
    <#assign tag = "" /> 
    
    <#list urlSections as urlSection>
        <#if urlSection_index gt 0 && urlSections[urlSection_index - 1] == "tag">        
            <#assign tag = urlSection />
        </#if>
    </#list>