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

发布于 2024-09-24 08:08:04 字数 122 浏览 0 评论 0原文

我想在 Zotonic 中添加每页侧边栏内容:

  • 链接
  • 白皮书
  • 网络研讨会

执行此操作的好方法是什么?我需要什么样的模板片段才能使其工作?

I would like to have per-page sidebar content in Zotonic:

  • Links
  • White papers
  • Webinars

What is a good way to do this and what kind of template snippets would I need to make it work?

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

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

发布评论

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

评论(1

握住我的手 2024-10-01 08:08:04

登录 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 %}

添加谓词时,它允许您将元数据添加到 Zotonic 中的 RSC(页面、媒体等)。每个谓词允许您将 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 类属性,该属性会更改链接样式以指示它是当前页面。

Log into the Zotonic admin interface.

Create Predicates:

  • Links (text->text)
  • White papers (text->document)
  • Webinars (text->text)

These predicates then show up in Page Connections in the Page editor. Add Links to other pages, links to White papers and links to Webinar pages in this way.

Add the following to _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 %}

When you add a Predicate it lets you add metadata to your RSCs (Pages, Media, etc.) in Zotonic. Each Predicate allows you to connect a collection of RSCs to a RSC in the Zotonic interface. This collection is stored and accessed as IDs of RSCs.

Predicate metadata are then accessible within templates. The expression m.rsc[id].links selects the collection of IDs of RSCs connected to the current page as Links.

The expression m.rsc[id] selects the RSC for the page being rendered. The expression m.rsc[text] selects the RSC for a onnected RSC.

The expression {% ifequal text id %}class="current"{% endifequal %} conditionally renders a CSS class attribute that alters the link style to indicate that it is the current page.

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