Blog News
| Browse in : |
All
> Topics
> CMS Blog
|
Xaraya Module Development Basics: Part 1
So, you've installed your own Xaraya site, have you? You've even created your own theme, added hacks to existing modules, and now you are ready to create your very own module?
First things first: you need to name your module. Give it a name that reflects the purpose of the module, possibly with some type of branding involved. For instance, when I release modules through MirageLab, I add "lab" to the beginning of the module name. This helps prevent confusion regarding what you are working on. Examples: labDossier, labPanels, labDocuments, et al.
Once you've decided on a name for your new module, it's time to register it. Go visit Xaraya.com and submit a new extension release for your module. Each module has it's own unique ID number, and you'll need to get yours in order for it to install properly.
Once you have a name and a number, you are ready to get started...
The key to creating a full working module is to have a full set of the basics available to start with. Most modules will involve the use of one or more tables. Using Xaraya, you can start building the basics by setting up your Version, Table and Initialization files/functions (xarversion.php, xartables.php and xarinit.php).
You can copy these files from another module since much of it becomes repetetive between modules, then go back through and update the contents to match thet module that you are creating. The Example and Dyn_Example modules are typical selections for this, although it is best to establish your own blank module fileset for rapid module creation.
Your module's version file (xarversion.php) will include the module's extension release ID and other reference information. Be sure to set your theme's CLASS equal to 2, so that it registers as a "user theme" that can actually be used.
Your Table (xartables.php) file will include meta data for the table names (and, sometimes, field names). Your module will likely rely extensively on this, since it will have to reference it each time that it interacts with the database, whether readind, writing or updating data.
Finally, your Initialization file (xarinit.php) will include the install, upgrade and delete functions for setting up and/or removing the module from active use on the website. Your Initialization function is where your database tables are actually created, using the Tables file data to reference field names. This is also where any module settings ("configuration variables") are first created, along with all security masks used by the module, definition of "instances" used by security to restrict access on a granular level, and creation of any "hooks" that your module will have.
Your Initialization file/function will also be where you create new Dynamic Data objects from XML schemas kept in one of your module's folders (I'm personally fond of using "xardata").
And, of course, in your Initialization file's delete function, you'll need to delete the tables used by the module, remove the masks and "instances" and "hooks", as well as any configuration variables that you established.
Note : Stay tuned for Part 2, where we look at all of the other little tertiary files that are either needed or helpful during module creation, like a hook for the Roles module to call for automatically placing a user preferences page specific to the module in the My Account section of your Xaraya website.
There are no comments attached to this item. You must be registered and logged in to post comments!
- Options:
- View Article Map
- View Archives