代码之家  ›  专栏  ›  技术社区  ›  Alain O'Dea

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

  •  3
  • Alain O'Dea  · 技术社区  · 14 年前

    • 链接
    • 网络研讨会

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

    1 回复  |  直到 14 年前
        1
  •  3
  •   Alain O'Dea    14 年前

    登录Zotonic管理界面。

    创建谓词:

    • 链接(文本->文本)
    • 白皮书(文本->文档)

    这些谓词随后显示在页面编辑器的页面连接中。以这种方式添加到其他页面的链接、到白皮书的链接和到网络研讨会页面的链接。

    将以下内容添加到 _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 %}
    

    然后可以在模板中访问谓词元数据。表达式 m.rsc[id].links 选择作为链接连接到当前页的rsc的id集合。

    表达式 m.rsc[id] m.rsc[text] 为连接的RSC选择RSC。

    表达式 {% ifequal text id %}class="current"{% endifequal %} 有条件地呈现CSS类属性,该属性改变链接样式以指示它是当前页。