我想拥有Zotonic的每页侧边栏内容:
做这件事的好方法是什么,我需要什么样的模板片段才能工作?
发布于 2010-09-23 13:51:17
登录到Zotonic管理界面。
创建谓词:
(text->text)
然后,这些谓词将显示在Page编辑器中的Page Connections中。以这种方式添加到其他页面的链接、到白皮书的链接和指向Webinar页面的链接。
将以下内容添加到_article_sidebar.tpl
{% with m.rsc[id].links as texts %}
{% if texts %}
<h2>See also:</h2>
<ul>
{% for text in texts %}
<li><a href="{{ m.rsc[text].page_url }}" {% ifequal text id %}class="current"{% endifequal %}>{{ m.rsc[text].title }}</a></li>
{% endfor %}
</ul>
{% endif %}
{% endwith %}
{% with m.rsc[id].white_papers as texts %}
{% if texts %}
<h2>White papers:</h2>
<ul>
{% for text in texts %}
<li><a href="{{ m.rsc[text].page_url }}" {% ifequal text id %}class="current"{% endifequal %}>{{ m.rsc[text].title }}</a></li>
{% endfor %}
</ul>
{% endif %}
{% endwith %}
{% with m.rsc[id].webinars as texts %}
{% if texts %}
<h2>Related webinars:</h2>
<ul>
{% for text in texts %}
<li><a href="{{ m.rsc[text].page_url }}" {% ifequal text id %}class="current"{% endifequal %}>{{ m.rsc[text].title }}</a></li>
{% endfor %}
</ul>
{% endif %}
{% endwith %}添加谓词时,它允许向RSC(页面、媒体等)添加元数据。在Zotonic。每个谓词允许您将RSC的集合连接到Zotonic接口中的RSC。此集合作为RSC的ID存储和访问。
然后,可以在模板中访问谓词元数据。表达式m.rsc[id].links选择连接到当前页面的RSC的ID集合作为链接。
表达式m.rsc[id]为呈现的页面选择RSC。表达式m.rsc[text]为一个已连接的RSC选择RSC。
表达式{% ifequal text id %}class="current"{% endifequal %}有条件地呈现一个CSS类属性,该属性更改链接样式以指示它是当前页。
https://stackoverflow.com/questions/3770466
复制相似问题