我有一个包含多个游戏类别的组件,我想根据类别显示不同的横幅。我需要可自定义横幅(和链接),因此这不仅仅是显示 categoryX.jpg
或其他内容。
我在另一个问题上看到了这个 Joomla 帮助页面,但它似乎只显示模块类型,而不显示一个特定的模块。我想使用各种 mod_custom
模块并显示适合该类别的模块(如果需要,我可以存储每个模块的 ID)。
有什么想法吗?
I have a component with several categories of games and I want to display a different banner depending on the category. I need the banner (and link) to be customizable so it's not simply a case of showing categoryX.jpg
or whatever.
I saw this Joomla help page on another question, but it only seems to display a module type, not one specific module. I'd like to use various mod_custom
modules and display the one appropriate to the category (I can store each module's ID if necessary).
Any ideas?
发布评论
评论(5)
这可以通过两步过程完成:
使用“将模块加载到文章”插件中,以允许您使用如下插件调用来访问模块:
{module [*mod_id*]} // 其中 *mod_id* 是模块 ID
现在您可以调用插件将模块放置在任何位置,现在您需要转到您想要添加模块的组件的视图代码并添加以下代码:
echo JHTML::_('content.prepare', '{module [*mod_id*]}');
请参阅此链接 - http://www.alltogetherasawhole。 org/group/developers/forum/topics/running-joomla-content-plugins - 关于第 2 点。我试图做同样的事情,但发现它不起作用,原因是您可以在上面的页面链接中找到一条评论:
“我注意到某些插件实际上期望 option=com_content 以便它们正确处理 onPrepareContent,因此您实际上可能想通过调用 JRequet::setVar 并恢复正确的值来“愚弄”它们触发后。”
This can be done in a 2 step process:
Use the "Load module into article" plugin to allow yourself to access the module using a plugin call like:
{module [*mod_id*]} // where *mod_id* is the module id
Now that you can call a plugin to put your module anywhere, you now need to go to the view code of your/a component you wish to add the module to and add this code:
echo JHTML::_('content.prepare', '{module [*mod_id*]}');
Please see this link - http://www.alltogetherasawhole.org/group/developers/forum/topics/running-joomla-content-plugins - regarding point number 2. I was trying to do the same thing and I found it didn't work, and the reason for this was a comment you can find on the page link above:
"I noticed that some plugin actually expect option=com_content for them to process onPrepareContent properly, so you might actually want to "fool" them by callin JRequet::setVar and restoring the correct values after the trigger."
如果您想在 PHP 代码中显示模块,请使用此代码,它对我有用:
如果您想在 html 内容中显示模块,则只需将此代码放在您想要显示模块的位置即可。
它加载分配给位置 2 的所有模块。
If you would like to show module within PHP code then use this code, it's worked for me :
If you want to show module inside html content then just put this code where you want to show module.
It loads all modules which are assigned to position-2.
您还可以使用 Joomla 模块渲染器
请注意,除了分配模块位置外,该模块还必须设置为“在所有页面上显示”。
You can also use the Joomla Module Renderer
Just a heads up, Along with being assigned the module position, that module also has to be set to "Display on All pages".
Joomla 内置了此功能。您可以在内容项中使用 {loadposition XX} 命令。您可以指定模板中未出现的自定义模块位置,以确保正确的文章中包含正确的模块。
http://docs.joomla.org/How_do_you_put_a_module_inside_an_article%3F
Joomla has this functionality built in. You can use the {loadposition XX} command within your content items. You can specify custom module positions that do not appear in your template to insure that you have the correct module in the correct article.
http://docs.joomla.org/How_do_you_put_a_module_inside_an_article%3F
您可以创建一个新模块吗?
如果每个类别都出现在查询字符串 (catid=X) 中,那么您可以采用与 https://support.pillwax.com/open-source/doku.php?id=joomla:header_image。
或者,该链接实际上可能会为您完成此操作。
You could create a new module?
If each category appears in the querystring (catid=X) then you could take a similar approach to https://support.pillwax.com/open-source/doku.php?id=joomla:header_image.
Alternatively, that link might actually do it for you.