DevWiki Index | DevWiki Tutorials
In the previous example we wrote about how to use a simple template. now we are going to use a template that relies more on the templating engine for the actual design.
Follow these steps to output our table using the template:
1.Create a folder named templates with a file "myTemplate.html" inside it containing this line:
<table><tr><td colspan='2' align='center'>My Module Table</td></tr>
<{section name=i loop=$myArray step=1}>
<{if $smarty.section.i.iteration % 2 == 0}>
<td><{$myArray[i]}></td>
</tr>
<{else}>
<tr>
<td><{$myArray[i]}></td>
<{/if}>
<{/section}>
</table>
2.Edit our xoops_version.php file to contain this line:
$modversion['templates'][1]['file'] = "myTemplate.html";
$modversion['templates'][1]['description'] = "Our template file";
3.Edit our index.php file to use the template, and assign the output to the template instead of using echo:
<?php //index.php
require_once("../../mainfile.php");
// this line must be defined BEFORE header.php
$xoopsOption['template_main'] = "myTemplate.html";
include XOOPS_ROOT_PATH."/header.php";
//Our Example Array
$myArray = array("Richard Nixon", "American Hero", "George W. Bush", "Vegetable", "Hoven Droven", "Swedish Folk Music done cool");
$xoopsTpl->assign('myArray', $myArray);
include XOOPS_ROOT_PATH."/footer.php";
?>
We see here that our array is assigned to the global Xoops object xoopsTpl as a smarty template variable named 'myArray'.
Other parts:
1.2.1 Using echo
1.2.2 Using a simple template
1.2.3 An active template
Back to DevWiki Tutorials











![[Main Page]](/modules/mediawiki/images/mediawiki.png)


