typo3在后端添加主菜单 [英] typo3 add a main menu in backend
问题描述
我正在尝试在typo3后端左侧的模块导航中添加一个新的主模块条目。我在网上发现应该通过 :: addModule
方法来实现此目的。
我正在这样尝试:
\TYPO3\CMS\Core\Utility\\ExtensionManagementUtility :: addModule(
'test',
'sub',
'',
'',
[
'labels'=>' LLL:EXT:eh_bootstrap /资源/私有/语言/locallang_mod_testxy.xlf',
'name'=>'test',
'iconIdentifier'=>'eh-bootstrap-icon',
'access'=>'user,group'
]
);
已阅读 ExtensionManagementUtility
类的方法
现在:如果我离开 $ sub
现在: >参数为空,则应在菜单中添加一个空白的主模块。但是,如果我这样做,则什么也没有显示。通过 $ sub
参数,将添加一个新的主模块及其子模块。
但是,主模块具有没有标签,我打算在主模块上使用的标签和图标现在正在为子模块添加标签。
以下是lang文件:
<?xml版本= 1.0编码= UTF-8?>
< xliff version = 1.0 xmlns:t3 = http://typo3.org/schemas/xliff>
< file t3:id = 1415816898 source-language = zh-CN datatype = plaintext original = messages date = 2011-10-17T20:22:34Z product-name = lang >
< header />
< body>
< trans-unit id = mlang_labels_tablabel>
< source> Testxy的东西< / source>
< / trans-unit>
< trans-unit id = mlang_tabs_tab>
< source> Testxy< / source>
< / trans-unit>
< / body>
< / file>
< / xliff>
关闭的标题标记使我有点失望,但是typo3中的其他xlf文件也有,所以我想它是有目的的。我主要从Web模块的lang文件中复制了此文件。
发现很难找到适用于Typo3的良好开发指南,到目前为止,没有一个指南对我有帮助这个问题。
添加:
我现在也尝试了
\TYPO3\CMS\Extbase\Utility\\ExtensionUtility :: registerModule(
'EHAERER。'。 $ _EXTKEY,
'test',
'ehbootstrap',
'',
[],
[
'labels'==>'LLL :EXT:eh_bootstrap /资源/私有/语言/locallang_mod_testxy.xlf',
'name'=>'test',
'iconIdentifier'=>'eh-bootstrap-icon',
'access'=>'user,group'
]
);
方法,因为该方法当前将子模块添加到空白标签的主模块中。如果我省略了子模块键,那么我的图标和标签将同时应用于主模块和空白子模块
使用以下代码在ext_tables.php中注册模块(或者至少这是我一直在做的事情)。
\TYPO3\CMS\Extbase\Utility\\ExtensionUtility :: registerModule(
'Vendor。'。$ _EXTKEY,
'web',//使模块成为任一'web'的子模块,'工具','管理工具','文件','帮助','系统','用户'
'm2',//子模块键
'底部',//位置:顶部,底部,之前:< submodulekey> ;、之后:< submodulekey>
array(
'Controller'=>'list,new,delete,edit',
),
array(
'access'=>'user,group',
'icon'=>'EXT:'。$ _EXTKEY。'/ext_icon.gif',
'标签'=>'LLL:EXT:'。$ _EXTKEY。'/Resources/Private/Language/locallang_m2.xlf',
)
);
编辑
请注意,听起来$ _EXTKEY可能会在将来被删除。代替使用$ _EXTKEY,您可以执行以下操作:
'Vendor.ExtensionName',// CamelCase $ b $中的供应商点扩展名b
I am trying to add a new main module entry to the module navigation on the left of the backend of typo3. I have found online that this should be possibel through the ::addModule
method.
I am trying it like this:
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addModule(
'test',
'sub',
'',
'',
[
'labels' => 'LLL:EXT:eh_bootstrap/Resources/Private/Language/locallang_mod_testxy.xlf',
'name' => 'test',
'iconIdentifier' => 'eh-bootstrap-icon',
'access' => 'user,group'
]
);
having read the ExtensionManagementUtility
-class the method should add a new main module when none with that particular name is known.
Now: If I leave the $sub
parameter empty, it should add a blank main module to the menu. If I do that however, nothing is shown. With the $sub
parameter a new main module is added along with its submodule.
However, the main module has no label and the label and icon that I intended for the main module is now labelling the sub module.
Here is the lang-file:
<?xml version="1.0" encoding="UTF-8"?>
<xliff version="1.0" xmlns:t3="http://typo3.org/schemas/xliff">
<file t3:id="1415816898" source-language="en" datatype="plaintext" original="messages" date="2011-10-17T20:22:34Z" product-name="lang">
<header/>
<body>
<trans-unit id="mlang_labels_tablabel">
<source>Testxy stuff</source>
</trans-unit>
<trans-unit id="mlang_tabs_tab">
<source>Testxy</source>
</trans-unit>
</body>
</file>
</xliff>
The closing header-tag put me off a bit, but other xlf-files in typo3 have that too, so I guess it has a purpose. I copied this mostly from the lang-file for the web-module.
It find it quite hard to find good development guides for Typo3 and none have helped me out so far with this problem. Any clue what I could be missing here is appreciated.
Adding:
I now also tried the
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule(
'EHAERER.' . $_EXTKEY,
'test',
'ehbootstrap',
'',
[],
[
'labels' => 'LLL:EXT:eh_bootstrap/Resources/Private/Language/locallang_mod_testxy.xlf',
'name' => 'test',
'iconIdentifier' => 'eh-bootstrap-icon',
'access' => 'user,group'
]
);
method, which as it is currently adds the submodule to a blankly labelled main Module. If I omit the submodule key, my Icon and label get applied to a both the Main Module and a blank Submodule
A backed module is registered using the following in your ext_tables.php (or at least this is how I've been doing it).
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule(
'Vendor.' . $_EXTKEY,
'web', // Make module a submodule of either 'web', 'tools', 'admin tools', 'file', 'help', 'system', 'user'
'm2', // Submodule key
'bottom', // Position: top, bottom, before:<submodulekey>, after:<submodulekey>
array(
'Controller' => 'list, new, delete, edit',
),
array(
'access' => 'user,group',
'icon' => 'EXT:' . $_EXTKEY . '/ext_icon.gif',
'labels' => 'LLL:EXT:' . $_EXTKEY . '/Resources/Private/Language/locallang_m2.xlf',
)
);
EDIT
Note that is sounds like $_EXTKEY may end up being removed in the future. Instead of using $_EXTKEY you can do:
'Vendor.ExtensionName', // Vendor dot Extension Name in CamelCase
这篇关于typo3在后端添加主菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!