The Geek
09-17-2005, 02:59 PM
A user asked the other day about using the GARS mod system to put Google Adsense after the article/tutorial/review/whatever. They figured it out quite quickly, however I saw this as a great opportunity to show others how to do it so that they can start to see how easy it is to write custom mods.
The module system is kind of similar to vB3.5's hook system in the fact that there are key sections that you can 'hook' into to provide extra functionality. Most of these key areas are for visual rendering, however there are plans to include additional 'hooks' in the editing and creating sections to allow users to record and edit custom fields without having to modify GARS at all!
There are currently 6 'hooks' where modules can produce output in an article/review/tutorial/whatever (so I don't have to keep typing that out - I'm going to call it a GAR from now on!).
Those locations are:
Above the GAR
Inside the header of the GAR
Between the header and content of the GAR
To the left of the GAR content (left column)
To the right of the GAR content (right column)
Below the GAR content.
In this tutorial, we are making a GARS module that holds Google Adsense. You could easily create a mod that holds whatever information you want by following the same steps.
Go into your style manager and create a new template called [B]GARS_google.
In the template code, put your Google Adsense code (or whatever HTML you want to appear).
Then save it. Make sure it is saved in each of your styles.
We start by creating a PHP file called google.php with the following code:
<?php
// make sure you clean any and all user input !!!
if ($stage == "display")
{
eval('$output .= "' . fetch_template('GARS_google') . '";');
}
else if ($stage == "settings")
{
print_description_row("This module will display Google Adsense");
}
?>
This is about as hard as it gets. Mods can get very complex, or they can be very simple like the code above. A couple of important points about creating mods like above:
$output is essential! Output is the variable that displays the HTML you want displayed. Without $output holding HTML, your results would be blank!
You must append the visual output ot the $output variable using the .= operator! If you simply put $output='my result'; then it would overwrite any previous mod output for that section!Save your mod file in the gars/mods folder and it will then be availible for you to add to GARS via the GARS->modules admincp option.
[break=Adding the mod setting]
Once your file has been created and saved in each of the gars/mods subfolders, you then need to add the mod to your GARS configuration.
In your AdminCP, click GARS -> Mods -> Add New and add the following information:
[B]Title: Google Adsense
File: google.php
Extra templates to cache: GARS_google
And then save it.
Then you can edit whichever types you want and add the mod wherever you want (i.e., in the bottom).
The mod system opens up the ability to modify and customize GARS like never before. Couple this with GARS already limitless forum/showthread morphing abilities and you have the ultimate in swiss army knifes for vBulletin.
[B]nJoy
The module system is kind of similar to vB3.5's hook system in the fact that there are key sections that you can 'hook' into to provide extra functionality. Most of these key areas are for visual rendering, however there are plans to include additional 'hooks' in the editing and creating sections to allow users to record and edit custom fields without having to modify GARS at all!
There are currently 6 'hooks' where modules can produce output in an article/review/tutorial/whatever (so I don't have to keep typing that out - I'm going to call it a GAR from now on!).
Those locations are:
Above the GAR
Inside the header of the GAR
Between the header and content of the GAR
To the left of the GAR content (left column)
To the right of the GAR content (right column)
Below the GAR content.
In this tutorial, we are making a GARS module that holds Google Adsense. You could easily create a mod that holds whatever information you want by following the same steps.
Go into your style manager and create a new template called [B]GARS_google.
In the template code, put your Google Adsense code (or whatever HTML you want to appear).
Then save it. Make sure it is saved in each of your styles.
We start by creating a PHP file called google.php with the following code:
<?php
// make sure you clean any and all user input !!!
if ($stage == "display")
{
eval('$output .= "' . fetch_template('GARS_google') . '";');
}
else if ($stage == "settings")
{
print_description_row("This module will display Google Adsense");
}
?>
This is about as hard as it gets. Mods can get very complex, or they can be very simple like the code above. A couple of important points about creating mods like above:
$output is essential! Output is the variable that displays the HTML you want displayed. Without $output holding HTML, your results would be blank!
You must append the visual output ot the $output variable using the .= operator! If you simply put $output='my result'; then it would overwrite any previous mod output for that section!Save your mod file in the gars/mods folder and it will then be availible for you to add to GARS via the GARS->modules admincp option.
[break=Adding the mod setting]
Once your file has been created and saved in each of the gars/mods subfolders, you then need to add the mod to your GARS configuration.
In your AdminCP, click GARS -> Mods -> Add New and add the following information:
[B]Title: Google Adsense
File: google.php
Extra templates to cache: GARS_google
And then save it.
Then you can edit whichever types you want and add the mod wherever you want (i.e., in the bottom).
The mod system opens up the ability to modify and customize GARS like never before. Couple this with GARS already limitless forum/showthread morphing abilities and you have the ultimate in swiss army knifes for vBulletin.
[B]nJoy