26 Aug 2008 @ 6:45 PM 

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.



  • Technorati
  • StumbleUpon
  • Reddit
  • del.icio.us
  • Facebook
  • MySpace
  • LinkedIn
  • Live
  • Sphinn
  • MisterWong
  • Slashdot
  • Tumblr
  • Wikio
  • Yahoo! Buzz
  • BlinkList
  • Google Bookmarks
  • Print
  • email
Posted By: Abe
Last Edit: 08 Aug 2009 @ 12:12 PM

EmailPermalink
Tags
Tags: , , , ,
Categories: Web Design


 

Responses to this post » (None)

 
Post a Comment

You must be logged in to post a comment.

Change Theme...
  • Users » 195
  • Posts/Pages » 37
  • Comments » 28
Change Theme...
  • VoidVoid « Default
  • LifeLife
  • EarthEarth
  • WindWind
  • WaterWater
  • FireFire
  • LightLight

DDO Forum



    No Child Pages.

Login



    No Child Pages.