如何使用 ZPT 检查它是否是 Plone 网站的主页?

发布于 2024-07-14 22:49:58 字数 190 浏览 5 评论 0 原文

我只想更改网站的标题(如果不是主页)。 是否有一个 tal:condition 表达式?

我一直在阅读,但找不到我要找的内容...

谢谢!

I want to change my website's header only it if's not the homepage. Is there a tal:condition expression for that?

I've been reading this and can't find what I'm looking for...

thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

缱倦旧时光 2024-07-21 22:49:58

最好的方法是使用两个非常方便的克隆视图,它们专门用于此目的。 定义它们的接口位于 https://svn.plone.org/svn/plone/plone.app.layout/trunk/plone/app/layout/globals/interfaces.py,以防您想查看。

<tal:block
   tal:define="our_url context/@@plone_context_state/canonical_object_url;
               home_url context/@@plone_portal_state/portal_url;"
   tal:condition="python:our_url == home_url">
HERE GOES YOUR STUFF
</tal:block>

@@plone_context_state 和 @@plone_portal_state 的伟大之处在于它们可以处理各种奇怪的边缘情况。 context/@@plone_context_state/canonical_object_url 也会返回正确的、最基本的对象 url,即使您正在查看门户根目录中附加了查询字符串的默认页面:-)

The best way is to use two really handy plone views that are intended just for this purpose. The interface that defines them is at https://svn.plone.org/svn/plone/plone.app.layout/trunk/plone/app/layout/globals/interfaces.py, in case you want to check it out.

<tal:block
   tal:define="our_url context/@@plone_context_state/canonical_object_url;
               home_url context/@@plone_portal_state/portal_url;"
   tal:condition="python:our_url == home_url">
HERE GOES YOUR STUFF
</tal:block>

The great thing about @@plone_context_state and @@plone_portal_state is that they handle all sorts of weird edge cases. context/@@plone_context_state/canonical_object_url also returns the right, most basic, object's url even when you're viewing the default page in the portal root with a query string appended :-)

没︽人懂的悲伤 2024-07-21 22:49:58

我使用类似于 axe 的东西:

<tal:block define="global currentUrl request/getURL" condition="python: u'home' not in str(currentUrl)">

<!-- whatever -->

</tal:block>

I use something similar to ax:

<tal:block define="global currentUrl request/getURL" condition="python: u'home' not in str(currentUrl)">

<!-- whatever -->

</tal:block>
荭秂 2024-07-21 22:49:58

类似 ...>` 怎么样?请参阅 TALES 内置名称Zope API 参考了解更多选择。

how about something like <tal:condition="python: request.URLPATH0 == '/index_html' ...>`? see TALES Built-in Names and the Zope API Reference for more choices.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文