User Login    
 + Register
  • Main navigation
Login
Username:

Password:

Remember me



Lost Password?

Register now!
Who's Online
75 user(s) are online (11 user(s) are browsing XoopsWiki)

Members: 3
Guests: 72

ozboof, deka87, Koeneke, more...
[Main Page]

MD-Tutorials

From XOOPS Project

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

Printable version | Disclaimers | Privacy policy
Category: ModuleDevelopment

This page needs editing

Module Development Tutorials,




- http://dev.xoops.org/dl/tinyeditor/docs/tinyeditor100.pdf
- http://dev.xoops.org/dl/tinyeditor/docs/tinyeditor1RC1.pdf
- http://dev.xoops.org/dl/tinyeditor/docs/tinyeditor_v101_en.pdf
- http://dev.xoops.org/dl/mx-directory/docs/MXD_RSS_Admin_Guide.pdf
- http://dev.xoops.org/dl/xhelp/docs/xhelp_user_documentation.pdf
- http://dev.xoops.org/dl/jiareports/docs/ReadMe.txt
- http://dev.xoops.org/dl/mx-directory/docs/MXD_Blocks_Admin_Guide.pdf
- http://dev.xoops.org/dl/xoops-fa/docs/system.pdf
- http://dev.xoops.org/dl/xoops_qa/docs/qa_roadmap_20050107-1.html
- http://dev.xoops.org/dl/xhelp/docs/Event_Service.txt
- http://dev.xoops.org/dl/cstand/docs/DB%20Design.pdf

Contents

2. Using a simple template file

In the previous example we wrote a string to the screen using echo. That may be fine for simple sites, but using a simple template will make the output blend better into the site layout. We'll introduce templates by outputting the string from the last example, but have in mind that this still isn't the "right" way to do it, as the HTML is still buried inside the PHP code.

A template is NOT a complete HTML file. It contains just the HTML code that you want to appear inside your module, and it does NOT contain any <head> or <body> tags.

Follow these steps to output our table using a minimal template:

1.Create a folder named templates with a file "myTemplate.html" inside it containing this line:

  • <{$content}>

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");
  • include_once "include/functions.php";
  • global $xoopsTpl;
  • // this line must be defined BEFORE header.php
  • $xoopsOption['template_main'] = "myTemplate.html";
  • include XOOPS_ROOT_PATH."/header.php";
  • $str = getTable();
  • $xoopsTpl->assign("content", $str);
  • include XOOPS_ROOT_PATH."/footer.php";
  •  ?>

We see here that our string is assigned to the global Xoops object xoopsTpl as a variable named "content". The contents of this variable will replace the <{$content}> in the template file.

This may be an OK way of doing thing if we're building a module with lots of pages where the layout is dynamic and we want to change things in php. But most of the HTML is still inside the php code, and we'd like to separate layout from content, so that's what we'll do next.

Other parts:

1.2.1 Using echo
1.2.3 Using an active template


Retrieved from "http://www.xoops.org/modules/mediawiki/index.php/MD-Tutorials"

This page has been accessed 1,887 times. This page was last modified 20:36, 9 February 2008. Content is available under XOOPS Project.


Developers for Hire
Developers for Hire
Local Support Sites
Make a donation
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


Powered by
XOOPS Code hosted on SourceForge

Powered by PHP

PHP 5

Powered by MySQL

Powered by Smarty

OSI certified

GPL

All content on this site is subject to the Creative Commons License
Top Tags
Theme (5) news (2) security (2) sport (1) Arabic (1) wiki (1) Christmas (1) jQuery (1) tag (1) module (1) SEO (1) comments (1)
Advertisement