PDA

View Full Version : Need random number in "header" template


forum_maniac
04-01-2006, 08:37 AM
I need a random number in the "header" template to randomly show different type of information. I know I can do this with Javascript but since some of the things I want to display is AdSense code I cannot use Javascript as I would have to slightly modify the AdSense code (which Google does not allow).

So I want to use a hook to define a variable and assign a random number between X and y to it. Then in the "header" template I use an <if> statement to evaluate the variable.

Questions:
- What hook should I use?
- What is the syntax of the variable in the hook?
- What is the syntax of the variable in the template?

You help is appreaciated.

sabret00the
04-07-2006, 03:50 PM
use global_start, the rest is very basic php

also i'd recomment using a $var in the template as opposed to conditionals on the template level.

forum_maniac
04-07-2006, 07:46 PM
use global_start, the rest is very basic php

also i'd recomment using a $var in the template as opposed to conditionals on the template level.
This is what I ended up doing:

- I used hook location "parse_templates" and used the following php code:
$random_number = rand(1, 8);
- I used the following syntax in the template "header"
<if condition="$random_number == 1">
code
</if>
...