Unique URLs in plone

407 views Asked by At

I have an internal link to sectionA/pageA in a sidebar, when I click it from sectionB the url becomes sectionB/sectionA/post. I cannot use absolute URL because the sidebar is in an XDV static file and I use linguaplone. How can I create unique url?

1

There are 1 answers

3
Martijn Pieters On

What you see a combination of a relative URL (not starting with a / or full URL including protocol and hostname) and acquisition. The latter means that sectionA can be reached still after traversing over sectionB. You'll have to use absolute URLs in the sidebar.

If you use a templating method to generate the sidebar (a ZPT pagetemplate, XDV, Diazo, etc.) you'll have to ensure you generate an absolute URL by either querying pageA directly for it's absolute url or any of it's ancestors and then add to the URL from there. Here are three TAL snippets that would achieve that:

 <!-- query pageA directly -->
 <a href="sectionA/pageA" tal:attributes="href sectionA/pageA/absolute_url"/> 

 <!-- start at sectionA and add to the URL from there -->
 <a href="sectionA/pageA" tal:attributes="href string:$(sectionA/absolute_url}/pageA"/> 

 <!-- assuming sectionA is in the site root, use that as the start -->
 <a href="sectionA/pageA" tal:attributes="href string:$portal_url/sectionA/pageA"/>

If you use an external templating system such as XDV, the same principles apply, but you won't be able to directly query either sectionA or pageA for their absolute URLs, but you will have absolute URLs to reconstruct a URL to them available, like the portal_url in the last example.