User Login    
 + Register
  • Main navigation
Login
Username:

Password:

Remember me



Lost Password?

Register now!
Who's Online
100 user(s) are online (8 user(s) are browsing XoopsWiki)

Members: 2
Guests: 98

ghia, deka87, more...
[Main Page]

Dev:start to make a module

From XOOPS Project

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

Printable version | Disclaimers | Privacy policy
Category: Development

Aspects

Two very important objects need to be understood in order to write a module for XOOPS: $xoopsUser and XoopsDB

Anatomy of a Module Page

A module file, which should be accessed via a browser URL (i.e. not files which will always be included in other files) should be in the modules/modulename folder.

The first thing a module page should do is include the root file "mainfile.php". Mainfile.php includes include/common.php which will:

   Setup the connection to the database
   Login the user if not anonymous
   Include the XOOPS API functions
   Retrieve the current module ($xoopsModule)
   Retrieve the module's configuration options ($xoopsModuleConfig)
   Include relevant language files
   Checks that the site is not closed - or if it is, that the user can access it
   Checks if the user has access to the current module

After the inclusion of mainfile.php, the module page should process anything necessary to decide on the template to be used - provided the page uses Smarty templates - with

   $xoopsOption['template_main'] = "template_name.ext";

The next step is to include the root file header.php, which will:

   Create the Smarty object, $xoopsTpl (Note: From 2.2, this is done in include/common.php)
   Check the page cache settings and
   either display the cached page or
   build the blocks to be displayed on the page

Note: If $xoopsOption['template_main'] is not set prior to the inclusion of header.php, the page cache will not kick in.

Now that the main parts of XOOPS have been included, the file can process the data to be shown on the page and assign variables to Smarty - if applicable. This can be any php code and as such doesn't have to be related to XOOPS although it should of course use the XOOPS core functionality where appropriate.

Here, $xoopsOption['output_type'] can also be set to "plain" if the page is to be displayed without any non-module content (like header, banner and blocks - usable e.g. in popup windows) - in which case the inclusion of header.php serves solely to check the page cache.

The file should end with including the root file footer.php, which will display the theme's theme.html with the blocks and module content retrieved earlier.

Note: Not including footer.php in a page using Smarty will result in a blank page with no content and no related error messages. If the page is not using Smarty, only the page's own content will be displayed without blocks, headers, footers and without the theme being applied.

Anatomy of a module Administration page

Admin pages should be in the modules/modulename/admin folder and have this structure:

include ('../../../include/cp_header.php'); xoops_cp_header();

//Module admin code similar to a frontside module page (Note: Before XOOPS 2.2, $xoopsTpl could not be used directly in the administration area, but would have to be manually instantiated or HTML output directly in the PHP files)

xoops_cp_footer();

Back to Main Page

Retrieved from "http://www.xoops.org/modules/mediawiki/index.php/Dev:start_to_make_a_module"

This page has been accessed 705 times. This page was last modified 01:54, 16 December 2007. 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