Forum Discussion

keithkelly's avatar
2 years ago

community urls frontPage Not Working on ToS Page

I'd like to build a link for our ToS that's like:

https://stage.community.duckcreek.com/html/assets/MyFile.pdf

So I used ${community.urls.frontPage} per this doc.

href="${community.urls.frontPage}/html/assets/MyFile.pdf"

which gave

https://stage.community.duckcreek.com/t5/custom/page/page-id/$%7Bcommunity.urls.frontPage%7D/html/assets/MyFile.pdf

Per above, it looks like there's a relative link assumption going on.

Per the ToS instruction text, I see "Select a language, and then click "View" to edit the Terms of Service. You can use HTML or plain text in the field. Text within these characters: "${ }" reuses a text string or URL that is defined elsewhere in the repository so that you don't have to retype it. URLs should not be changed to preserve links back to pages in the community."

Any tips on how to build this URL conditionally so it works on Stage and Prod?

  • MattV's avatar
    MattV
    Khoros Staff

    For anything in assets, use asset.get. So your freemarker would be ${asset.get("/html/assets/MyFile.pdf")}, which will automatically generate the full URL for you.

    The other benefit to using asset.get is it will generate a URL that leverages the CDN for the asset to improve performance.

    • MattV's avatar
      MattV
      Khoros Staff

      Correction; I didn't fully read your post.

      Somewhat confusingly, the value in ${ } needs to reference a text key, and can't actually parse freemarker.

      If you want to link to that file in your ToS, you're probably better off just making a relative link directly to it, e.g. <a href="/html/assets/MyFile.pdf">Link Here</a>

      But, if you were actually in Freemarker land, you would use asset.get as I noted before.

  • Hi keithkelly ,

    I tried building URL on my end and it worked fine on my end.
    Can you try without the '/' before the "html" and see if that solves the issue?

    " href="${community.urls.frontPage}html/assets/MyFile.pdf "


    Give Kudos if you find this Helpful or mark this as Solution if it answers your query.