Twig Grav模板--未列出子页面的细枝
我已经在grav中用这样的分类法制作了几页Twig Grav模板--未列出子页面的细枝,twig,grav,Twig,Grav,我已经在grav中用这样的分类法制作了几页 - Home (category type) - programming (category type) - stuff (category type) - stuff1 (page type) - stuff2 (page type) - stuff3 (page type) 我还制作了一个名为“category”的模板类型,希望它能抓住stuff1/2/3的所有链接,并将它们作为链接放在“stuff”页面上。我的代码看起来
- Home (category type)
- programming (category type)
- stuff (category type)
- stuff1 (page type)
- stuff2 (page type)
- stuff3 (page type)
我还制作了一个名为“category”的模板类型,希望它能抓住stuff1/2/3的所有链接,并将它们作为链接放在“stuff”页面上。我的代码看起来有点像这样:
{% block body %}
{% block content %}
<ul>
{% for p in self.children %}
<li><a href="{{p.url}}">{{ p.title }}</a></li>
{% endfor %}
</ul>
{% endblock %}
{% endblock %}
{%block body%}
{%block content%}
{self.children%中p的%s}
{%endfor%}
{%endblock%}
{%endblock%}
最终目标是为孩子们提供一个简单的链接列表,比如:
<ul>
<li><a href="/stuff1">stuff1</a></li>
<li><a href="/stuff2">stuff2</a></li>
<li><a href="/stuff3">stuff3</a></li>
</ul>
我尝试过使用page.children、self.children和其他一些东西,但似乎没有任何东西能让它按我希望的方式工作
任何帮助都将不胜感激。恐怕我不太明白您所说的“类别类型”和“页面类型”是什么意思 上面的文档可能会很有帮助 示例: 如果要使用模板“category.html.twig”显示包含特定类别(或标记)的所有页面的URL列表的页面,可以执行以下操作:
content:
items:
'@taxonomy.category': mycategory
<ul>
{% for p in page.collection() %}
<li><a href="{{p.url}}">{{p.title}}</a></li>
{% endfor %}
</ul>
{page.collection()中p的%s}
{%endfor%}
<ul>
<li><a href="/site-stack">Home</a></li>
<li><a href="/site-stack/blog/hero-classes">Body & Hero Classes</a></li>
</ul>