k4/k4navigation
Composer 安装命令:
composer require k4/k4navigation
包简介
Advanced navigation and breadcrumb Plugin (Twig filter) for Craft CMS 3.x
README 文档
README
Craft Plugin Twig filter for advanced navigations in Craft CMS.

Installation
To install k4navigationCraft3, follow these steps:
- Install with Composer via
composer require k4/k4navigationfrom your project directory.
k4navigation works with Craft 3.0 or later.
k4navigation Overview
Twig filter for advanced navigations in Craft CMS.
Using k4navigation
First, set your Menu in craft.
{% set entries = craft.entries()
.section('pages')
.level(1)
.with(['descendants'])
.all()
%}
{% set mainnavigation %}
{% for entry in entries %}
<li>
<a href="{{ entry.url }}">
{{ entry.title }}
{% if entry.hasDescendants %}
<i class="fas fa-caret-down"></i>
{% endif %}
</a>
{% nav node in entry.descendants %}
...
{% endnav %}
</li>
{% endfor %}
{% endset %}
Now you can use the k4-navigation twig filter. See the examples below:
Simple add class "active" to all Parent-Elements of selected item
{{ mainnavigation | k4NavigationGetActivePath(url(craft.app.request.pathInfo)) | raw }}
Simple Menu shows only first level and also selected path
{{ mainnavigation | k4NavigationGetSimpleNavigation(url(craft.app.request.pathInfo)) | raw }}
Show Breadcrumb for menu
{{ mainnavigation | k4NavigationGetBreadcrumb(url(craft.app.request.pathInfo)," > ") | raw }}
Generate Navigation menu with first level navigation only
{{ mainnavigation | k4NavigationGetFirstNavOnly(craft.app.request.absoluteUrl) | raw }}
Generate Navigation menu excluding first level items (submenu only)
{{ mainnavigation | k4NavigationGetSubNavOnly(craft.app.request.absoluteUrl) | raw }}
Brought to you by Thomas Bauer
统计信息
- 总下载量: 544
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-01-24