PDA

View Full Version : Ad ing some Sense


The Geek
09-17-2005, 03: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

greg watson
09-18-2005, 08:32 PM
So is there a way to put this "inline" in the GAR content? Ideally located "Left Inline" or "Right Inline" ...

Greg

The Geek
09-18-2005, 09:27 PM
You could put it in a column, either the left or right. Is that what you mean?

greg watson
09-20-2005, 12:44 AM
You could put it in a column, either the left or right. Is that what you mean?
No ... inline in the GAR content block ...

Something like this where x is content in the GAR content block and y is the inline block within the GAR content block ...

xxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxx yyyyyyy
xxxxxxxxxxx yyyyyyy
xxxxxxxxxxx yyyyyyy
xxxxxxxxxxx yyyyyyy
xxxxxxxxxxx yyyyyyy
xxxxxxxxxxx yyyyyyy
xxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxx

Greg

Loco
03-11-2006, 08:33 AM
could u just add the FLOAT LEFT and FLOAT RIGHT
to your bbcode described in this post at vb.org
http://www.vbulletin.org/forum/showthread.php?t=103257 ?

greg watson
03-11-2006, 03:49 PM
could u just add the FLOAT LEFT and FLOAT RIGHT
to your bbcode described in this post at vb.org
http://www.vbulletin.org/forum/showthread.php?t=103257 ?

That is awfully close ... using this I can get this:

yyyyyyxxxxxxxxxxxxx
yyyyyyxxxxxxxxxxxxx
yyyyyyxxxxxxxxxxxxx
yyyyyyxxxxxxxxxxxxx
yyyyyyxxxxxxxxxxxxx
yyyyyyxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxx

I am sure you could also float this to the right ...

I think this is better than what we currently have ... readers are trained to ignore ads in a left hand column without other content ... so the current module structure just isn't the best long term solution for ads.

Does anyone know how to force this block down 5+ lines?

Greg

pcoskat
03-27-2006, 12:50 PM
Are there any screen shots of the 'placement' examples in the tutorial?

Loco
03-28-2006, 09:22 AM
Does anyone know how to force this block down 5+ lines?

Greg
type 5 lines before adding the bbcode ?

MissKalunji
07-19-2006, 10:16 PM
does anyone knows how to make that work with 2.0?

The Geek
07-19-2006, 10:28 PM
I need to make some code base changes. Most likely a 2.0 version will be out next week.

HTHs

MissKalunji
07-19-2006, 10:29 PM
Ok thanks dear

chrisj8221
09-23-2006, 03:55 AM
anyone have a screenshot of this?

The Geek
09-23-2006, 10:30 AM
This is pretty old as its for version 1.01. TO be honest, the easiest way to do this would GARS 2,0 would be with this-> http://www.thevbgeek.com/showthread.php?t=2055

chrisj8221
09-24-2006, 12:47 AM
ok - will try to wade through it.

thanks

chris