Templates 如何为Joomla模块使用多个模板文件

Templates 如何为Joomla模块使用多个模板文件,templates,module,joomla,joomla1.5,Templates,Module,Joomla,Joomla1.5,我正在尝试创建自己的模块,我遵循了以下教程: 下面的代码位于文件“/modules/mod\u hello\u world2/mod\u hello\u world2.php”中 // get the items to display from the helper $items = ModHelloWorld2Helper::getItems($userCount); // include the template for display require(JModuleHelper::ge

我正在尝试创建自己的模块,我遵循了以下教程:

下面的代码位于文件“/modules/mod\u hello\u world2/mod\u hello\u world2.php”中

// get the items to display from the helper
$items = ModHelloWorld2Helper::getItems($userCount);
 
// include the template for display
require(JModuleHelper::getLayoutPath('mod_hello_world2'));
这段代码显示了“/modules/mod_hello_world2/tmpl/default.php”的内容,其中解析了$items的数据

现在我想知道是否以及如何调用不同的模板文件。 我想为表单创建一个,为结果创建另一个。 因为将代码和HTML分开是最好的做法,所以我想这样做


欢迎任何帮助

JModuleHelper::getLayoutPath为布局提供了一个可选的、进一步的参数

所以

require(JModuleHelper::getLayoutPath('mod_hello_world2', 'mylayout'));

在mod_your_module.php中使用以下命令:

$layout = $params->get('layoutChoice'); 
require(JModuleHelper::getLayoutPath('mod_your_module', $layout ));
MOD_LAYOUT_CHOICE="Choose which Template to Use"
MOD_LAYOUT_CHOICE_DESC="Your discription for each template is written hire"
MOD_LAYOUT_CHOICE_DEFAULT="First Template"
MOD_LAYOUT_CHOICE_DEFAULT2="Second Template"
MOD_LAYOUT_CHOICE_DEFAULT3="Third Template"
MOD_LAYOUT_CHOICE_DEFAULT4="Forth Template"
然后在mod_your_module.xml中写入以下内容:

<field name="layoutChoice" type="list" default="default" label="mod_layout_choice" description="mod_layout_choice_description" >
    <option value="default">default</option>
    <option value="default2">default2</option>
    <option value="default3">default3</option>
    <option value="default4">default4</option>
</field>

Thnx Kissaki,这正是我想要的。
MOD_LAYOUT_CHOICE="Choose which Template to Use"
MOD_LAYOUT_CHOICE_DESC="Your discription for each template is written hire"
MOD_LAYOUT_CHOICE_DEFAULT="First Template"
MOD_LAYOUT_CHOICE_DEFAULT2="Second Template"
MOD_LAYOUT_CHOICE_DEFAULT3="Third Template"
MOD_LAYOUT_CHOICE_DEFAULT4="Forth Template"