GRAV子导航 [英] GRAV subnavigation
本文介绍了GRAV子导航的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试使用 GRAV CMS创建我的第一个网站。
现在我的 pages-folder
看起来像这样:
< nav class =role =navigation>
< div class =>
< ol class =>
{%page.children%中的页面}
{%if page.visible%}
{%set current_page =(page.active or page.activeChild)? 'active':''%}
{%endif%}
{%endfor%}
< / ol>
< / div>
< / nav>
有没有办法显示所有页面,包括导航中的子页面?
感谢您的回答...
解决方案
您的导航中的儿童(子页面):
< nav class =role =navigation>
< div class =>
< ol class =>
{%page.children%中的页面}
{%if page.visible%}
{%set current_page =(page.active or page.activeChild)? 'active':''%}
{%if page.children%}
{%为page.children%中的子元素}
{%if child.visible%}
{%endif%}
{%endfor%}
< / ol>
{%endif%}
{%endif%}
{%endfor%}
< / ol>
< / div>
< / nav>
I try to make my first site with GRAV CMS.
Now in my pages-folder
it looks like this:
- home/default.md
- about
- about/seite1/default.md
- about/seite2/default.md
Now, if i put the following code into my html-file, only the main points are showed in the navigation.
<nav class="" role="navigation">
<div class="">
<ol class="">
{% for page in pages.children %}
{% if page.visible %}
{% set current_page = (page.active or page.activeChild) ? 'active' : '' %}
<li class="{{ current_page }}"><a href="{{ page.url }}">{{ page.menu }}</a</li>
{% endif %}
{% endfor %}
</ol>
</div>
</nav>
Is there a way to show all the pages, including subpages in the navigation?
thanks for your answer...
解决方案
This should give you the fist level of children (subpages) in your navigation:
<nav class="" role="navigation">
<div class="">
<ol class="">
{% for page in pages.children %}
{% if page.visible %}
{% set current_page = (page.active or page.activeChild) ? 'active' : '' %}
<li class="{{ current_page }}"><a href="{{ page.url }}">{{ page.menu }}</a></li>
{% if page.children %}
<ol class="">
{% for child in page.children %}
{% if child.visible %}
<li class="{{ current_page }}"><a href="{{ child.url }}">{{ child.menu }}</a></li>
{% endif %}
{% endfor %}
</ol>
{% endif %}
{% endif %}
{% endfor %}
</ol>
</div>
</nav>
这篇关于GRAV子导航的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文