模块开发
$params->get("count", "0"); //在modules中获取参数
选择模板:
require JModuleHelper::getLayoutPath('mod_menu', 'default');
<jdoc:include type="modules" name="top" style="xhtml" /> //模块组位,name在xml文件上描述
<jdoc:include type="component" style="xhtml" /> //组件位
style是可选的,可选值定义在/templates/system/html/modules.php,能添加新的style
$this->countModules('left') //如果left有模块显示,则返回true
模块输出到任何位置:
$module = JModuleHelper::getModule('custom',$title);
echo JModuleHelper::renderModule($module);
模板位置:
----------------------------------
/templates/xxxx/index.php //模板页面,php和html描述
templateDetails.xml //模板结构描述
/element/template_thumbnail.png //140*90的截图
/element/css/template_css.css //模板CSS
---------------------------------
模板配置文件:
<files> 部分包含模板涉及到的重要文档
<images> 部分包含涉及到的图片文件
<css> 部分是css文件
<languages> 不用说是语言文件
<positions> 定义了模板中的模块位置
<params> 模板中的参数
<filename>params.ini</filename>
<folder>images/</folder>
$this->baseurl
$this->language;
$this->params->get('widthStyle') //在视图中获取参数
$this->template //当前模板名
$user= JFactory::getUser();
自定义模块style:
function modChrome_{style_name}($module, &$params, &$attribs)
{
$url = isset($attribs['url']) ? $attribs['url'] : '#'; //接收参数
if (!empty ($module->content)) : ?>
<div class="moduletable<?php echo $params->get('moduleclass_sfx'); ?>">
<?php if ($module->showtitle != 0) : ?>
<h3><?php echo $module->title; ?><a href="<?php echo $url ?>">Read More</a></h3>
<?php endif; ?>
<?php echo $module->content; ?>
</div>
<?php endif;
}
插件开发
插件在plugins目录里以插件类型命名的目录下。每个类型都有个example.php的例子可以作为建立插件类与事件处理的参考。