GARS: Module making 101
Module creation in GARS is actually VERY simple once you get your head around the framework. If you know a tad bit of HTML and a tad bit of PHP, obs your uncle and GARS is your friend.
In this Tutorial, Ill introduce you to making your own modules that allow you to easily grab extra data and display it. Please note that this is a bare bones example with little fluff designed to show you a BARE minimal approach. It is also to try and help a user that was asking for this functionality :) What Ill do is create a module that will allow users to select a rating for the imaginary 'movie' they are rating. In essence, all we will be doing is providing a combo box at edit/new thread time, capturing the input and then displaying the results when someone reads the entry. Make sure you clean the input! Here is the code in its entirety: PHP Code:
The first thing you will notice is how everything is broken into 'stages'. In total, there are 5 stages:
The edit stage provides you with the ability to add additional fields for the user to enter when they create a new thread or edit an existing thread. Here all we are doing is creating a drop down combo box with a selection of items to choose from and appending it to the $output variable: PHP Code:
Your HTML elements need to be named custom1[MYVARNAME] in order to work. You MYVARNAME should be unique as well! Another note: Whatever output you want to produce MUST be APPENDED to the $output variable. In other words: PHP Code:
PHP Code:
the persist stage is where we save whatever custom entries we want to save. The first thing we do is capture the variable from the GPC: PHP Code:
PHP Code:
This is where we layout the custom fields how we want. Since I'm using the GARS_mod_container template (which gives you the expandable box), I set the title: PHP Code:
PHP Code:
Then we use the handy eval command to paste it all together into the $output variable (note how it is appended to output instead of assigned!) PHP Code:
To wind this up, simply save it as a php file in your geek/gars/mods folder. You can then register it and assign it to any module set. It will be pretty useless in a forumdisplay page, so I would recommend adding it to a showthread module set page. nJoy |
wow thanks useful stuff ^^
|
All times are GMT. The time now is 09:36 AM. |
Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Tutorial powered by GARS 2.1.9 ©2005-2006