首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何支持Zotonic中的每页侧边栏内容?

如何支持Zotonic中的每页侧边栏内容?
EN

Stack Overflow用户
提问于 2010-09-22 14:49:55
回答 1查看 323关注 0票数 3

我想拥有Zotonic的每页侧边栏内容:

  • Links
  • White papers
  • Webinars

做这件事的好方法是什么,我需要什么样的模板片段才能工作?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2010-09-23 13:51:17

登录到Zotonic管理界面。

创建谓词:

(text->text)

  • White

  • Links (text->document)

  • Webinars (text->text)

然后,这些谓词将显示在Page编辑器中的Page Connections中。以这种方式添加到其他页面的链接、到白皮书的链接和指向Webinar页面的链接。

将以下内容添加到_article_sidebar.tpl

代码语言:javascript
复制
{% 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类属性,该属性更改链接样式以指示它是当前页。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3770466

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档