How do you maintain the sidebar content of each page in Zotonic?

I would like to have the contents of the sidebar of each page in Zotonic:

  • References
  • White papers
  • Webinars

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

+3
source share
1 answer

Log in to the Zotonic administration interface.

Create Predicates:

  • Links (text-> text)
  • Paper (text-> document)
  • Webinars (text-> text)

These predicates are then displayed in Page Links in the page editor. Add links to other pages, links to documents, and links to web pages this way.

_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. Predicate RSC RSC Zotonic. RSC.

. m.rsc[id].links RSC, .

m.rsc[id] RSC . m.rsc[text] RSC RSC.

{% ifequal text id %}class="current"{% endifequal %} CSS, , , .

+3

Source: https://habr.com/ru/post/1766012/


All Articles