plone中的唯一网址

时间:2011-04-21 09:46:20

标签: url plone xdv linguaplone

我在侧边栏中有sectionA / pageA的内部链接,当我从sectionB点击它时,url变为sectionB / sectionA / post。我不能使用绝对URL,因为侧边栏位于XDV静态文件中,我使用linguaplone。 如何创建唯一网址?

1 个答案:

答案 0 :(得分:3)

您看到的是相对网址的组合(不是以/或完整网址开头,包括协议和主机名)和获取。后者意味着在遍历sectionA之后仍可以到达sectionB。您必须在侧栏中使用绝对URL。

如果您使用模板方法生成侧边栏(ZPT pagetemplate,XDV,Diazo等),您必须确保通过直接查询pageA为其绝对URL或其中任何一个祖先来生成绝对URL然后从那里添加到URL。以下是三个可实现此目标的TAL片段:

 <!-- 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"/>

如果您使用外部模板系统(如XDV),则适用相同的原则,但您无法直接查询sectionA或pageA的绝对URL,但您将拥有绝对URL来重建URL的URL可用,如上一个示例中的portal_url