Joomla -- 查找菜单项的所有翻译

2022-01-06 00:00:00 php multilingual joomla

我使用 Joomla 2.5 和 Language-Switcher 模块和插件来构建多语言网站.

I am using Joomla 2.5 with the Language-Switcher Module and Plugin to built an multilingual site.

主要问题是:切换语言总是会导致翻译的主页,而不是翻译的菜单项.所以我遇到了问题,以找到菜单项的所有翻译.

The main problem is: switching the language always leads to the translated homepage, but not to the translated menu-item., so I ran into the problem to find all translations of an Menu item.

基于内部结构,语言过滤器只过滤具有合适语言设置的页面项目.因此,每个菜单项、链接或 url 都是唯一的,不可能为每个翻译的菜单项定义类似根"菜单项的内容.是否可以创建一个在菜单项创建表单中插入新按钮的插件?

Based on the internal Structure, the Language-filter only filters the page items with suitable language settings. So each menu item, or link, or url is unique and it is not possible to define something like a 'root' menu item for every translated menu item. Is it possible to create a Plugin that inserts a new button in the menu-item-creation-form?

问候菲利普

推荐答案

成功了!搜索translations"并没有得到正确的结果,而是搜索associations"解决了这个问题.我在查看写入的 com_menus 文件的代码时找到了答案:

Got it Working! Searching for "translations" did not lead to proper results, instead searching for "associations" solved it. I found the answer while looking into code of the com_menus files where is written:

$associations = MenusHelper::getAssociations( $active->id );

就是这样,我只需要通过以下方式注册 MenusHelper 类:

That's all, I just needed to register the MenusHelper class via:

JLoader::register('MenusHelper', JPATH_ADMINISTRATOR . '/components/com_menus/helpers/menus.php');

相关文章