contao-community-alliance / nested-menu
Contao OpenSource CMS 的嵌套菜单
Requires
- php: >=5.3
- contao-community-alliance/composer-plugin: ~2
- contao-community-alliance/contao-twig: ~1.11
- contao/core: >=2.11,<4
Requires (Dev)
- phpcq/all-tasks: ~1.0
Replaces
- bit3/contao-nested-menu: 1.1.5
- contao-legacy/nested-menu: 1.1.5
This package is auto-updated.
Last update: 2024-09-06 08:47:12 UTC
README
 
嵌套菜单 的好处是减少后台菜单项的数量并将它们分组到子菜单中。
定义嵌套菜单项
首先你需要一个带有许多项目的导航设置。
$GLOBALS['BE_MOD']['my'] = array( 'entry1' => array( 'tables' => array('table1'), ), 'entry2' => array( 'tables' => array('table2'), ), 'entry3' => array( 'tables' => array('table3'), ), 'entry4' => array( 'tables' => array('table4'), ), 'entry5' => array( 'tables' => array('table5'), ), 'entry6' => array( 'tables' => array('table6'), ), 'entry7' => array( 'tables' => array('table7'), ), 'entry8' => array( 'tables' => array('table8'), ), 'entry9' => array( 'tables' => array('table9'), ), );
现在你需要定义哪个项目将被嵌套到另一个项目中。
$GLOBALS['BE_MOD']['my'] = array( 'entry1' => array( 'tables' => array('table1'), ), 'entry2' => array( 'tables' => array('table2'), ), 'entry3' => array( 'tables' => array('table3'), ), 'entry4' => array( 'tables' => array('table4'), ), 'entry5' => array( 'nested' => 'grouped_entries', 'tables' => array('table5'), ), 'entry6' => array( 'nested' => 'grouped_entries', 'tables' => array('table6'), ), 'entry7' => array( 'nested' => 'grouped_entries', 'tables' => array('table7'), ), 'entry8' => array( 'nested' => 'grouped_entries', 'tables' => array('table8'), ), 'entry9' => array( 'nested' => 'grouped_entries', 'tables' => array('table9'), ), );
现在将创建一个 虚拟 结构,看起来像这样
$GLOBALS['BE_MOD']['my'] = array( 'entry1' => array( 'tables' => array('table1'), ), 'entry2' => array( 'tables' => array('table2'), ), 'entry3' => array( 'tables' => array('table3'), ), 'entry4' => array( 'tables' => array('table4'), ), 'grouped_entries' => array( 'callback' => 'NestedMenuController', ), );
请注意,条目 entry5
到 entry9
只是对用户隐藏的。
新的项目 grouped_entries
现在提供了一个类似于从 Contao 2 后台首页知道的 旧 导航列表。
也可以在子菜单中创建不同的组,只需在 nested
键中添加 :group-name
。
$GLOBALS['BE_MOD']['my'] = array( 'entry1' => array( 'tables' => array('table1'), ), 'entry2' => array( 'tables' => array('table2'), ), 'entry3' => array( 'tables' => array('table3'), ), 'entry4' => array( 'tables' => array('table4'), ), 'entry5' => array( 'nested' => 'grouped_entries:group1', 'tables' => array('table5'), ), 'entry6' => array( 'nested' => 'grouped_entries:group1', 'tables' => array('table6'), ), 'entry7' => array( 'nested' => 'grouped_entries:group2', 'tables' => array('table7'), ), 'entry8' => array( 'nested' => 'grouped_entries:group2', 'tables' => array('table8'), ), 'entry9' => array( 'nested' => 'grouped_entries:group3', 'tables' => array('table9'), ), );
现在 entry5
和 entry6
将被分组,entry7
和 entry8
也将被分组,并且 entry9
也会有自己的组。
翻译
每个子菜单组都需要在 $GLOBALS['TL_LANG']['MOD']
数组中有一个语言键,等于组名。
$GLOBALS['TL_LANG']['MOD']['grouped_entries:group1'] = 'Group 1'; $GLOBALS['TL_LANG']['MOD']['grouped_entries:group2'] = 'Group 2'; $GLOBALS['TL_LANG']['MOD']['grouped_entries:group3'] = 'Group 3';
安全
因为嵌套菜单只是一个视觉修改,你可以为每个单个菜单项(包括分组项本身)授予或限制访问权限。你不会错过 Contao 提供的所有权限。