八 06
近来在测试Joomla,想实现的一个功能是将Joomla中的模块加入到单元/分类的介绍中,在后台管理中似乎没有这样的设置,而修改模板index.html文件,增加新的position也无法达到想要的效果。最后在Joomla!中文技术讨论区中寻求帮助,终于找到了解决方法。
一、最新版(1.5.3以上)中,可以在单元/分类介绍中直接加入如下代码:
{loadposition ***}
然后在模块管理中,将希望插入到介绍部分的模块位置设置为***(与loadposition后面的位置一致)。这样就可以在介绍部分插入相应的模板了,但是因为css的问题,模块样式会消失。要如何实现css,我还没有测试,大概可以通过模块管理中的css后缀,进行修改。
二、其他版本(1.5.*)安装loadmodule_for_category_description_v1.5插件,可以在文章中任意位置加入模块
- 下载安装。安装时,在joomla后台管理:扩展-》安装卸载—》上传压缩包文件-》选择下载好的zip文件进行安装
- 在扩展-》插件管理中启用loadmodule for Section/Category Description
- 在分类介绍模板中增加触发器
打开<Joomla root folder>/components/com_content/views/category, 找到view.html.php- 打开该文件,转到39行,在其后加入下面的代码
-
$category =& $this->get('Category'); $dispatcher =& JDispatcher::getInstance(); JPluginHelper::importPlugin('content'); $results = $dispatcher->trigger('onBeforeDisplayTitle', array (& $category));
- 保存
- 在单元介绍模板中增加触发器
打开<Joomla root folder>/components/com_content/views/section, 找到view.html.php- 打开该文件,转到39行,在其后加入下面的代码
-
$section =& $this->get('Section'); $dispatcher =& JDispatcher::getInstance(); JPluginHelper::importPlugin('content'); $results = $dispatcher->trigger('onBeforeDisplayTitle', array (& $section));
- 转到87行,加入
-
$dispatcher =& JDispatcher::getInstance(); JPluginHelper::importPlugin('content'); for($i = 0; $i < count($categories); $i++) { $category =& $categories[$i]; $category->link = JRoute::_('index.php?view=category&id='. $category->slug); $results=$dispatcher->trigger('onBeforeDisplayTitle', array(&$category)); } if ($total == 0) { $params->set('show_categories', false); }
- 保存
- 在单元/分类介绍,或者文章内容的任意地方加入{loadposition ***},然后再在模块管理中设置模块位置为***,就可以实现在介绍或者文章中插入模块。
参考内容:
- How to include modules in Content item (for Joomla 1.5.x)
- How to allow plugins/mambots to work inside of Section/Categories?
更新:
文章中提到新增加的模块css问题,可以在单元/分类介绍中使用HTML编辑,这样就可以设置新加入模块的css了,例如:
<div class = "module heading"> {loadposition ***} </div>
Recent Comments