Include js on select paes using templets

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
seeker2921
Forum Contributor
Posts: 120
Joined: Sat Mar 22, 2003 7:10 pm
Location: Wiesbaden Germany
Contact:

Include js on select paes using templets

Post by seeker2921 »

So I have my site set up to use a templete.. So I have all the main HTML in my index.php and then wheret he content is supposed to go I have this code

Code: Select all

<?
if(!isset($go)) 
{ 
    include("home.php"); 
} 
else 
{ 
    for($i=0; i<count($links); $i++) 
    { 
        if($go==$links[$i]) 
        { 
            include($url[$i]); 
            break; 
        } 
    } 
} 
?>
So that pulls the other pages into the index.php creating a temeplet system, Thats simple But what I need is I need to include JS in the header only on select pages so say I want to include a JS script on index.php?go=about but I don't want that JS code on any of the other pages.. How would I do this?

Thanks and I hope I explained my problem well enough..
ghost007
Forum Commoner
Posts: 49
Joined: Sat Nov 22, 2003 10:10 am

Post by ghost007 »

hi,

you can use a if statement in the home.php file:
<?
if (go=="about"){
?>

Code: Select all

<?}?>
Rest of html

hope this helps
Siech
Post Reply