studioespresso/craft-navigate
Composer 安装命令:
composer require studioespresso/craft-navigate
包简介
Navigation plugin for Craft CMS
README 文档
README
Menu's & navigations made easy.
Requirements
This plugin works with Craft CMS 3.x, 4.x and 5.x
Installation
To install the plugin, follow these instructions.
cd /path/to/project
composer require studioespresso/craft-navigate
./craft install/plugin navigate
Templating
craft.navigate.raw
craft.navigate.raw will give you an array of the items you added to the navigation, with children for each if you have those.
For each node you will have access to:
{% set nav = craft.navigate.raw('navHandle') %}
{% for node in nav %}
{{ node.name }}
{{ node.url }}
{{ node.classes }}
{{ node.blank }}
{{ node.children }}
{% endfor %}
This gives you complete control over the HTML & CSS used to display your navigation.
Here's an example of how to show a navigation and it's possible children using a twig macro:
{% import _self as macros %}
{% macro renderNode(node) %}
{% import _self as macros %}
<li class="{% if node.classes|length %}{{ node.classes }}{% endif %}">
<a href="{{ node.url }}" class="{% if node.active %}active{% endif %}"
{% if node.blank %}target="_blank" rel="noopener"{% endif %}>{{ node.name }}
</a>
{% if node.children|length %}
<ul>
{% for child in node.children %}
{{ macros.renderNode(child) }}
{% endfor %}
</ul>
{% endif %}
</li>
{% endmacro %}
<div>
<ul>
{% for node in nodes %}
{{ macros.renderNode(node) }}
{% endfor %}
</ul>
</div>
Headings
Since 2.3.0, headings can be added to make it easier to build larger navigations with mulitple sections or columns. To make full use of this you check check node.type == "heading" and add the html you need in the condition.
These only work on multiple levels (eg: 3 headings on the top level, each with navigation items on deeper levels).
Configuration
You can create a file called navigate.php in the config directory (you can copy this one to start) to manage these settings in your code. The ones listed here are not available through the CP.
Disabling caching
Out of the box, the plugin will cache the querries it makes when devMode is not enabled.
If you want to disable caching within the plugin entirely, you can do so by setting disableCaching to true in the plugin's configuration file. (see example here)
CSS class option list
Instead of the "Classes" field being a plain text field, you can also change it to a predefined dropdown with class that you want to make available for the user.
The nodeClasses setting takes an array where that contains "Class to be applied" => "Label to be shown in the cp".
"nodeClasses" => [ '' => '---', 'nav nav-primary' => "Primary", 'nav nav-highlight' => 'Highlight' ]
Make sure to also include an empty option in case you don't want the the first item to be selected by default
Brought to you by Studio Espresso
studioespresso/craft-navigate 适用场景与选型建议
studioespresso/craft-navigate 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 43.16k 次下载、GitHub Stars 达 26, 最近一次更新时间为 2018 年 06 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「cms」 「navigation」 「menus」 「Craft」 「craftcms」 「craft-plugin」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 studioespresso/craft-navigate 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 studioespresso/craft-navigate 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 studioespresso/craft-navigate 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A block to display a list of links to child pages, or pages in current level
GraphQL authentication for your headless Craft CMS applications.
Set Links with a specific language parameter
Supercharged text field validation.
Menu View Generator Using Livewire
Nested Set Model for Laravel
统计信息
- 总下载量: 43.16k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 26
- 点击次数: 13
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: proprietary
- 更新时间: 2018-06-30