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

 

Link to comment
Share on other sites

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?

 

Link to comment
Share on other sites

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/

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.