The vB Geek

The vB Geek (http://www.thevbgeek.com/index.php)
-   Tutorials (http://www.thevbgeek.com/forumdisplay.php?f=12)
-   -   Ad ing some Sense (http://www.thevbgeek.com/showthread.php?t=175)

The Geek 09-17-2005 02:59 PM

Ad ing some Sense
 
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:
  1. Above the GAR
  2. Inside the header of the GAR
  3. Between the header and content of the GAR
  4. To the left of the GAR content (left column)
  5. To the right of the GAR content (right column)
  6. 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 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 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.


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:

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.

nJoy

greg watson 09-18-2005 07: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 08:27 PM

You could put it in a column, either the left or right. Is that what you mean?

greg watson 09-19-2005 11:44 PM

Quote:

Originally Posted by The Geek
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 07: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 02:49 PM

Quote:

Originally Posted by LoCo.M
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 11:50 AM

Are there any screen shots of the 'placement' examples in the tutorial?

Loco 03-28-2006 08:22 AM

Quote:

Originally Posted by greg watson
Does anyone know how to force this block down 5+ lines?

Greg

type 5 lines before adding the bbcode ?

MissKalunji 07-19-2006 09:16 PM

does anyone knows how to make that work with 2.0?

The Geek 07-19-2006 09:28 PM

I need to make some code base changes. Most likely a 2.0 version will be out next week.

HTHs


All times are GMT. The time now is 06:05 PM.

Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

Tutorial powered by GARS 2.1.9 ©2005-2006