WatsonN Posted May 17, 2010 Share Posted May 17, 2010 What I am trying to do is setup a static theme page and the title just call a variable. So in order to do this I need to figure out how to make ($FooTitle == $title) I know the echo in the code below isnt right either but its all I could come up with to make it fail... <?php if ($url == $s1) { echo($AIWTDtitle == $title) ; } elseif ($url == $s2) { echo($LMtitle == $title); } elseif ($url == $s3) { echo($TMLtitle == $title); } elseif ($url == 'home') { echo($HOMEtitle == $title); } ?> Thanks in advanced (: Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted May 17, 2010 Share Posted May 17, 2010 One "=" for assignment, two "==" for comparison, so <?php if ($url == $s1) { $AIWTDtitle =$title ; } elseif ($url == $s2) { $LMtitle = $title; } elseif ($url == $s3) { $TMLtitle = $title; } elseif ($url == 'home') { $HOMEtitle = $title; } ?> But, this would make more sense: <?php if ($url == $s1) { $title = $AIWTDtitle; } elseif ($url == $s2) { $title = $LMtitle; } elseif ($url == $s3) { $title = $TMLtitle; } elseif ($url == 'home') { $title = $HOMEtitle; } echo $title; ?> Ken Quote Link to comment Share on other sites More sharing options...
WatsonN Posted May 17, 2010 Author Share Posted May 17, 2010 Thank you. But when i tried that I could not get it to set a title. My index file looks like this: <?php require('variables.php') ?> <?php require('Header.php') ?> <?php require('Top.php') ?> <?php $url = (isset($_GET['p']) ? $_GET['p'] : home); ?> <?php if ($url == $s1) { include($l1); } elseif ($url == $s2) { include($l2); } elseif ($url == $s3) { include($l3); } else { include($home); } ?> <?php require('Bottom.php') ?> title:<?php echo $title; ?> The title script is in the var file. I tried it in the index file too and it wouldn't work there either. I put the echo at the bottom to see if that would return anything either and it didn't. Is this possible? Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted May 17, 2010 Share Posted May 17, 2010 Can you show is the code for your include files? I don't see where you're using the variable. Quote Link to comment Share on other sites More sharing options...
WatsonN Posted May 17, 2010 Author Share Posted May 17, 2010 Sure thing variables.php <?php $s1 = "AIWTD-Sugarland" ; $s2 = "LM-MontgomeryGentry" ; $s3 = "TML-JeremyCamp" ; $home = "home.php" ; $l1 = "Lyrics/Sugarland/All-I-Want-To-Do.php" ; $l2 = "Lyrics/Montgomery-Gentry/Lucky-Man.php" ; $l3 = "Lyrics/Jeremy-Camp/Take-My-Life.php" ; $AIWTDtitle = "All I Want To Do - Sugarland ~ Nathan Watson" ; $LMtitle = "Lucky Man - Montgomery Gentry ~ Nathan Watson" ; $TMLtitle = "Take My Life - Jeremy Camp ~ Nathan Watson" ; $HOMEtitle = "Welcome ~ Nathan Watson" ?> <?php if ($url == $s1) { $title = $AIWTDtitle; } elseif ($url == $s2) { $title = $LMtitle; } elseif ($url == $s3) { $title = $TMLtitle; } elseif ($url == 'home') { $title = $HOMEtitle; } echo $title; ?> Header.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <script language="Javascript" type="text/javascript" src="ajax.js"></script> <script type='text/javascript' src='http://watsonn.com/openx/www/delivery/spcjs.php?id=1'></script> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <?php echo "<title> ".$title." </title>"; ?> <meta name="OffLimits" content="" /> <link href="/default.css" rel="stylesheet" type="text/css" media="screen" /> </head> <body> Top.php <a name="top"> <!-- start header --> <?php include $_SERVER['DOCUMENT_ROOT'] . '/menu.php'; ?> <!-- end header --> <div id="header"> <div id="logo"> <h1><a href="#">NathanWatson</a></h1> <p>The OFFICIAL home page</p> </div> <div id="splash"> <?php include $_SERVER['DOCUMENT_ROOT'] . '/twitter.php'; ?> </div> </div> <div id="wrapper"> <!-- start page --> <div id="page"> <div id="page-bgtop"> <div id="page-bgbtm"> <!-- start content --> <div id="content"> <?php include $_SERVER['DOCUMENT_ROOT'] . '/song.php'; ?> <!-- <?php include("var.php"); ?> --> <div class="post"> <a name="post1"> Bottom.php </div> </div> <!-- end content --> <!-- start sidebars --> <?php include('sidebar1.php'); ?> <?php include $_SERVER['DOCUMENT_ROOT'] . '/sidebar2.php'; ?> <!-- end sidebars --> <div style="clear: both;"> </div> </div> </div> </div> <?php include $_SERVER['DOCUMENT_ROOT'] . '/quotes.php'; ?> <!-- end page --> </div> <div id="footer"> <?php include $_SERVER['DOCUMENT_ROOT'] . '/footer.php'; ?> </div> <a name="bottom"> </body> </html> The page where this is implemented is http://WatsonN.com/Lyrics/ Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted May 17, 2010 Share Posted May 17, 2010 Where is the varialble $url being set? If that's not set, then the variable $title will not be set. Ken Quote Link to comment Share on other sites More sharing options...
WatsonN Posted May 17, 2010 Author Share Posted May 17, 2010 $url is being set in the index file <?php $url = (isset($_GET['p']) ? $_GET['p'] : home); ?> Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted May 17, 2010 Share Posted May 17, 2010 But you're setting the $title in variables.php which is included before that line is executed. Also, the line should be <?php $url = (isset($_GET['p']) ? $_GET['p'] : 'home'); ?> Ken Quote Link to comment Share on other sites More sharing options...
WatsonN Posted May 17, 2010 Author Share Posted May 17, 2010 I knew there was going to be something little like that that I missed. the new code: <?php $url = (isset($_GET['p']) ? $_GET['p'] : 'home'); ?> <?php require('variables.php') ?> <?php require('Header.php') ?> <?php require('Top.php') ?> <?php if ($url == $s1) { include($l1); } elseif ($url == $s2) { include($l2); } elseif ($url == $s3) { include($l3); } else { include($home); } ?> <?php require('Bottom.php') ?> Thank you very much Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted May 17, 2010 Share Posted May 17, 2010 You don't have keep going in & out of PHP: <?php $url = (isset($_GET['p']) ? $_GET['p'] : 'home'); require('variables.php'); require('Header.php'); require('Top.php'); if ($url == $s1) { include($l1); } elseif ($url == $s2) { include($l2); } elseif ($url == $s3) { include($l3); } else { include($home); } require('Bottom.php'); ?> Ken Quote Link to comment Share on other sites More sharing options...
WatsonN Posted May 17, 2010 Author Share Posted May 17, 2010 Diffrent writing styles Thank ya I'll use that one Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.