User Login    
 + Register
  • Main navigation
Login
Username:

Password:

Remember me



Lost Password?

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

Members: 5
Guests: 77

Runeher, hackbrill, Alex_Grey, khinlau, caek9, more...
[Main Page]

Dev:module architecture

From XOOPS Project

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

Printable version | Disclaimers | Privacy policy
Category: Development

These rules should be applied by all development projects on this site:

Contents

Reduced SQL query count

Great pains should be taken to reduce the amount of queries needed on a page. This means: No queries in xoops_version.php unless in current module

This means that if you use queries to determine submenu items in the main menu, first put a check to see if your module is current module with a

   global $xoopsModule;
   if (is_object($xoopsModule) && $xoopsModule->getVar('dirname') != $modversion['dirname']) {


No queries within loops

If you need information based on a previous query, loop through the results of the first query to find the items needed in the second query and retrieve all that information in one go.

   e.g. instead of retrieving user information inside a loop of articles, first retrieve the articles, then find the userID's, you need, and then retrieve user information for the found userID's


Improve readability

Nobody likes to read a page full of complex processing and SQL queries


Place complex processing in functions or class methods

If you are doing complex processing, put it in a function or a class method with a descriptive name. If you should need the same processing done later, you have a handy function for it.

Place all SQL queries in functions or class methods

There should be no need for SQL queries outside functions or class methods. It greatly improves readability to have only descriptive calls to functions or class methods instead of SQL queries and subsequent going throught the resultset.

Use XOOPS Form library

Forms should be in included files, using the XoopsForm library. It is an easy way to have a form and will make it easier to modify and add elements to it.

Use of the $xoopsModule->getVar('dirname')

Don't hardcode your module dirname in your php files and templates. We can translate the module content, if you use this we can translate the module name too with a small change in the module's xoops_version.php (E.G. An Italian website doesn't needs a wordbook module, but it needs a 'dizionario' one) Since Xoops v. 2.0.10 a new smarty var is added in the core, <{$xoops_dirname}>, that return the module dirname so you can use this in your templates - if an absolute path is needed.

Use Templates

Can't be stressed enough. Templates complete the MVC separation of the code and is a very important part of making modules easy to understand.

You have tools - use them!

Back to the Main Page

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

This page has been accessed 575 times. This page was last modified 01:52, 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