I was recently offered an deal by an agency for my Free Online Arcade.
I use a PHP and MySQL based content management script called AV Arcade for most of the web site because it saves me hours of programming and design.
The were interested in displaying a text advert show near the top of only my home page. I played with the PHP template system for a while, but could not find a clean and simple way to insert the code into the page (As the whole site is one PHP page, modulated).
Instead of adding functions and inclusions in several files of the AV Arcade template system, I needed an easier way to include the advert on one page only.
After asking the great font of all knowing (google) then playing with the code a little, I came up with this…
<?php $homepageadz = "/"; $currentpage = $_SERVER['REQUEST_URI']; if($homepageadz==$currentpage) { echo('ads n stuff');} else{ echo(''); } ?>
The example php code below can be used to detect the current page and show output
It’s a good idea to learn about $_SERVER and $_SERVER['REQUEST_URI'].
I used echo(‘ads n stuff’) to stop T_String errors when inserting adsense code or, more specifically, when using the “ character.
If you have to use “ in the echo output, remember to escape quote. I.e. \”
I know this is fairly basic and not going to impress anyone. But this quick fix can help until getting use to an alien templating system!
You could also extend it to detect other pages or make a simple admin page for it etc etc.

Categories
Tag Cloud
Blog RSS
Comments RSS

Void « Default
Life
Earth
Wind
Water
Fire
Light 