Jump to content

Title Vars and elseif


WatsonN

Recommended Posts

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 (:

Link to comment
https://forums.phpfreaks.com/topic/201996-title-vars-and-elseif/
Share on other sites

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

 

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?

 

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/

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 :D

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.