Get XOOPS XOOPSXOOPS FAQFAQ ForumsForums NewsNews ThemesThemes ModulesModules

Search

Donate to XOOPS!

Please select an amount to donate


Do you want your username revealed with your donation?
Yes - List me as a Generous Donor
No - List my donation as from an Anonymous Donor


Local Support

Advertisement

XOOPS Code hosted on SourceForge

Cumulus Tag Cloud

admin Arabic banner block Christmas comments cumulus DayDawn dhsoft e-Commerce E-Learning Git Google GUI hacks instant-zero jQuery module mygalleries news Nordic Olédrion oxygen PageRank PHP rmcommon security SEO simple-XOOPS Smarty sport tag Theme tutorial wiki WOX xoops XoopsEngine ZendFramework

New Users

Registering user

# 133948

guilhermeans

Welcome to XOOPS!
[Main Page]

Making a simple module: An active template

From XOOPS Web Application System

Main Page | Recent changes | Edit this page | Page history | Switch to MediaWiki mode

Printable version | Disclaimers | Privacy policy
Category: DevWiki

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

Retrieved from "http://xoops.org/modules/mediawiki/index.php/Making_a_simple_module:_An_active_template"

This page has been accessed 4,556 times. This page was last modified 19:12, 24 July 2009. Content is available under XOOPS Web Application System.