dd/evolutioncms-snippets-ddmenubuilder
Composer 安装命令:
composer require dd/evolutioncms-snippets-ddmenubuilder
包简介
Simple and flexible template-driven menu builder. Initially inspired by combination of the Wayfinder and Ditto advantages with significant code simplification.
关键字:
README 文档
README
Simple and flexible template-driven menu builder. Initially inspired by combination of the Wayfinder and Ditto advantages with significant code simplification.
Requires
- PHP >= 5.6
- (MODX)EvolutionCMS >= 1.1
- (MODX)EvolutionCMS.libraries.ddTools >= 0.59
Installation
Using (MODX)EvolutionCMS.libraries.ddInstaller
Just run the following PHP code in your sources or Console:
//Include (MODX)EvolutionCMS.libraries.ddInstaller require_once( $modx->getConfig('base_path') . 'assets/libs/ddInstaller/require.php' ); //Install (MODX)EvolutionCMS.snippets.ddMenuBuilder \DDInstaller::install([ 'url' => 'https://github.com/DivanDesign/EvolutionCMS.snippets.ddMenuBuilder', 'type' => 'snippet' ]);
- If
ddMenuBuilderis not exist on your site,ddInstallerwill just install it. - If
ddMenuBuilderis already exist on your site,ddInstallerwill check it version and update it if needed.
Manually
1. Elements → Snippets: Create a new snippet with the following data
- Snippet name:
ddMenuBuilder. - Description:
<b>2.2</b> Simple and flexible template-driven menu builder.. - Category:
Core → Navigation. - Parse DocBlock:
no. - Snippet code (php): Insert content of the
ddMenuBuilder_snippet.phpfile from the archive.
2. Elements → Manage Files:
- Create a new folder
assets/snippets/ddMenuBuilder/. - Extract the archive to the folder (except
ddMenuBuilder_snippet.php).
Parameters description
Data provider parameters
Providers get documents data to output.
-
provider- Desctription: Name of the provider that will be used to fetch documents.
- Valid values:
'parent''select'
- Default value:
'parent'
-
providerParams- Desctription: Parameters to be passed to the provider.
- Valid values:
stringJsonObject— as JSONstringHjsonObject— as HJSONstringQueryFormatted— as Query string- It can also be set as native PHP object or array (e. g. for calls through
\DDTools\Snippet::runSnippetor$modx->runSnippet):arrayAssociativeobject
- Default value: —
Providers → Parent (&provider=`parent` )
Select children documents from required parent(s).
-
providerParams->parentIds- Desctription: Parent IDs — the starting points for the menu. Specify '0' to start from the site root.
- Valid values:
arraystringCommaSepareted
- Default value:
'0'
-
providerParams->parentIds[i]- Desctription: Parent ID.
- Valid values:
integerDocumentID - Required
-
providerParams->depth- Desctription: The depth of documents to build the menu.
- Valid values:
integer - Default value:
1
Providers → Select (&provider=`select` )
Just output selected documents.
-
providerParams->ids- Desctription: Document IDs.
- Valid values:
arraystringCommaSepareted
- Required
-
providerParams->ids[i]- Desctription: Document IDs.
- Valid values:
integerDocumentID - Required
General parameters
-
sortDir- Desctription: The sorting direction (by
menuindexfield). - Valid values:
'ASC''DESC'
- Default value:
'ASC'
- Desctription: The sorting direction (by
-
showPublishedOnly- Desctription: Show only published documents.
- Valid values:
01
- Default value:
1
-
showInMenuOnly- Desctription: Show only documents visible in the menu.
- Valid values:
01
- Default value:
1
Template parameters
templates- Desctription: Templates.
Placeholders available in all templates:[+id+][+menutitle+]— will be equal to[+pagetitle+]if empty.[+pagetitle+][+published+][+isfolder+][+totalAllChildren+][+totalThisLevelChildren+][+level+]
- Valid values:
stringJsonObject— as JSONstringHjsonObject— as HJSONstringQueryFormatted— as Query string- It can also be set as native PHP object or array (e. g. for calls through
\DDTools\Snippet::runSnippetor$modx->runSnippet):arrayAssociativeobject
- Default value: —
- Desctription: Templates.
Item templates
-
templates->item- Desctription: The menu item template.
- Valid values:
stringChunkNamestring— use inline templates starting with@CODE:
- Default value:
'@CODE:<li><a href="[~[+id+]~]" title="[+pagetitle+]">[+menutitle+]</a></li>'
-
templates->itemHere- Desctription: The menu item template for the current document.
- Valid values:
stringChunkNamestring— use inline templates starting with@CODE:
- Default value:
'@CODE:<li class="active"><a href="[~[+id+]~]" title="[+pagetitle+]">[+menutitle+]</a></li>'
-
templates->itemActive- Desctription: The menu item template for a document which is one of the parents to the current document when the current document doesn't displayed in the menu (e. g. excluded by the
depthparameter). - Valid values:
stringChunkNamestring— use inline templates starting with@CODE:
- Default value: =
templates->itemHere
- Desctription: The menu item template for a document which is one of the parents to the current document when the current document doesn't displayed in the menu (e. g. excluded by the
-
templates->itemUnpub- Desctription: The menu item template for unpublished document (when
showPublishedOnly==0). - Valid values:
stringChunkNamestring— use inline templates starting with@CODE:
- Default value: =
templates->item
- Desctription: The menu item template for unpublished document (when
-
templates->itemUnpubActive- Desctription: The menu item template for unpublished document which is one of the parents to the current document when the current document doesn't displayed in the menu (e. g. excluded by the
depthparameter). - Valid values:
stringChunkNamestring— use inline templates starting with@CODE:
- Default value: =
templates->itemActive
- Desctription: The menu item template for unpublished document which is one of the parents to the current document when the current document doesn't displayed in the menu (e. g. excluded by the
Parent item templates
-
templates->itemParent- Desctription: The menu item template for documents which has a children displayed in menu.
- Valid values:
stringChunkNamestring— use inline templates starting with@CODE:
- Default value:
'@CODE:<li><a href="[~[+id+]~]" title="[+pagetitle+]">[+menutitle+]</a><ul>[+children+]</ul></li>'
-
templates->itemParentHere- Desctription: The menu item template for the current document when it has children displayed in menu.
- Valid values:
stringChunkNamestring— use inline templates starting with@CODE:
- Default value:
'@CODE:<li class="active"><a href="[~[+id+]~]" title="[+pagetitle+]">[+menutitle+]</a><ul>[+children+]</ul></li>'
-
templates->itemParentActive- Desctription: The menu item template for a document which has the current document as one of the children.
- Valid values:
stringChunkNamestring— use inline templates starting with@CODE:
- Default value: =
templates->itemParentHere
-
templates->itemParentUnpub- Desctription: The menu item template for unpublished documents which has a children displayed in menu.
- Valid values:
stringChunkNamestring— use inline templates starting with@CODE:
- Default value: =
templates->itemParent
-
templates->itemParentUnpubActive- Desctription: The menu item template for an unpublished document which has the current document as one of the children.
- Valid values:
stringChunkNamestring— use inline templates starting with@CODE:
- Default value: =
templates->itemParentActive
Outer template
-
templates->outer- Desctription: Wrapper template.
Available placeholders:[+children+]— Generated HTML with all items.
- Valid values:
stringChunkNamestring— use inline templates starting with@CODE:
- Default value:
'@CODE:<ul>[+children+]</ul>'
- Desctription: Wrapper template.
-
placeholders- Desctription:
Additional data has to be passed into the
templates->outer.
Arrays are supported too:some[a]=one&some[b]=two=>[+some.a+],[+some.b+];some[]=one&some[]=two=>[+some.0+],[some.1]. - Valid values:
stringJsonObject— as JSONstringHjsonObject— as HJSONstringQueryFormatted— as Query string- It can also be set as native PHP object or array (e. g. for calls through
\DDTools\Snippet::runSnippetor$modx->runSnippet):arrayAssociativeobject
- Default value: —
- Desctription:
Additional data has to be passed into the
Examples
All examples are written using HJSON, but if you want you can use vanilla JSON instead.
Providers → Parent
[[ddMenuBuilder?
&provider=`parent`
&providerParams=`{
parentId: 1
depth: 2
}`
]]
Providers → Select
[[ddMenuBuilder?
&provider=`select`
&providerParams=`{
ids: [
1
2
3
]
}`
]]
Pass additional data into outer chunk (the placeholders parameter)
[[ddMenuBuilder?
&templates=`{
outer:
'''
@CODE:<ul class="[+class+]">[+children+]</ul>[+somePlaceholder2+]
'''
}`
&placeholders=`{
class: someClass
somePlaceholder2: <p>Some value for placeholder.</p>
}`
]]
Using Query string instead of JSON
JSON syntax is more clear than Query string, but sometimes it's not convenient. For example, if you want to pass JSON string as string.
[[ddMenuBuilder?
&provider=`parent`
&providerParams=`parentId=1&depth=2`
&templates=`outer=general_nav`
&placeholders=`pladeholder1={"someName": "someValue"}&pladeholder2={"name": "John"}`
]]
Run the snippet through \DDTools\Snippet::runSnippet without DB and eval
//Include (MODX)EvolutionCMS.libraries.ddTools require_once( $modx->getConfig('base_path') . 'assets/libs/ddTools/modx.ddtools.class.php' ); //Run (MODX)EvolutionCMS.snippets.ddMenuBuilder \DDTools\Snippet::runSnippet([ 'name' => 'ddMenuBuilder', 'params' => [ 'providerParams' => [ 'parentId' => 1 ] ] ]);
Links
dd/evolutioncms-snippets-ddmenubuilder 适用场景与选型建议
dd/evolutioncms-snippets-ddmenubuilder 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 05 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「menu」 「navigation」 「modx」 「MODX Evo」 「evo」 「modx evolution」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 dd/evolutioncms-snippets-ddmenubuilder 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 dd/evolutioncms-snippets-ddmenubuilder 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 dd/evolutioncms-snippets-ddmenubuilder 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A block to display a list of links to child pages, or pages in current level
A Symfony extension to get active class base on current bundle/controller/action
Laravel Menu management
Yii2 DynaTree Menu widget uses Dynamic tree view control jquery.dynatree.js
Create simple top navigation for laravel
GUI for monitoring usage in real-time for appui
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 30
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2023-05-05