View Full Version : Using GAB on non-standard templates

02-06-2008, 06:48 PM

GAB is working properly when i insert into standard templates (i.e. header, footer, navbar), but is not displaying when i insert them into custom templates. (i am displaying these custom templates via GARS).

i have read the threads below regarding this problem, but cannot seem to solve it. any idea on what i need to do to have GAB run in custom templates?


02-07-2008, 06:27 PM
Those would be the correct threads, and it depends on where the custom templates are being fetched. PHP has this thing called scope, and that basically means that not all variables are available in all locations. The $GAB_ads variable is available after the global_start hook, but if you want it to be accessible in functions, scope comes into play, whereby you'd need to add the following line to the start of said functions:

global $GAB_ads;

02-11-2008, 03:28 PM
so i need to add

global $GAB_ads;

to the code? but where? plugins or templates? or somewhere else?


02-11-2008, 05:39 PM
I cannot tell you where to add the line of code because I don't know where your custom templates are being fetched. If you search the GARS PHP files for fetch_template you will see that it appears in a number of files, plus there are possibly other places the line of code would need to go. You'd need to tell me more about the custom templates (where you set them, what they do, where they appear, possibly screenshots) for me to get a clue.

02-11-2008, 09:18 PM
hi morgan,

here is some more information, perhaps you can point me in the right direction:

1. i am placing the GAB variables in a custom template
2. i am then putting this custom template in a GARS module

the custom templates do not have anything but the GAB variable in them.

thanks for your patience and help thus far.

02-11-2008, 10:31 PM
Did you create a new PHP file for the module? If so, add global $GAB_ads; to the top of the file. If not, try editing the run_mod function in the gars_class_core.php file, adding the part in bold red:

if ($stage == "display")
$values =& $this->data['custom1'][$itemid];
global $vbcollapse, $show, $post, $GAB_ads;

02-12-2008, 02:00 PM
that worked! thanks a lot for your help morgan. :)