TeamPhotoshop
Reviews, updates and in depth guides to your favourite mobile games - AppGamer.com
Forum Home Latest Posts Search Help Subscribe

PHP: Page Titles

Page: 1 Reply
Feb 26th 2002#33165 Report
Member since: Mar 18th 2001
Posts: 1452
Ok, I've got 1 file called magickingdom.php (I'm working on my Disney site if it makes you wonder, heh).

In the page, I'm including multiple other files, for the text of each attraction, etc.

This is what I'm using (this isn't the part I'm having a problem with though)

if ($location == "" && $attraction == "") {
include('http://thewaltdisneynut.com/parks/magickingdom/mkmain.php');
} elseif ($location == "mainstreet" && $attraction == "") {
include('http://thewaltdisneynut.com/parks/magickingdom/mainstreet/mainstreetmain.php');
} elseif ($location == "adventureland" && $attraction == "") {
include('http://thewaltdisneynut.com/parks/magickingdom/adventureland/adventuremain.php');
} elseif ($location == "frontierland" && $attraction == "") {
include('http://thewaltdisneynut.com/parks/magickingdom/frontierland/frontiermain.php');
} elseif ($location == "libertysquare" && $attraction == "") {
include('http://thewaltdisneynut.com/parks/magickingdom/libertysquare/libertymain.php');
} elseif ($location == "fantasyland" && $attraction == "") {
include('http://thewaltdisneynut.com/parks/magickingdom/fantasyland/fantasymain.php');
} elseif ($location == "toontown" && $attraction == "") {
include('http://thewaltdisneynut.com/parks/magickingdom/toontown/toontownmain.php');
} elseif ($location == "tomorrowland" && $attraction == "") {
include('http://thewaltdisneynut.com/parks/magickingdom/tomorrowland/tomorrowmain.php');

} elseif ($location == "adventureland" && $attraction == "junglecruise") {
include('http://thewaltdisneynut.com/parks/magickingdom/adventureland/junglecruise.php');
} elseif ($location == "adventureland" && $attraction == "pirates") {
include('http://thewaltdisneynut.com/parks/magickingdom/adventureland/pirates.php');
} elseif ($location == "adventureland" && $attraction == "treehouse") {
include('http://thewaltdisneynut.com/parks/magickingdom/adventureland/treehouse.php');
} elseif ($location == "adventureland" && $attraction == "aladdin") {
include('http://thewaltdisneynut.com/parks/magickingdom/adventureland/aladdin.php');
} elseif ($location == "adventureland" && $attraction == "tikiroom") {
include('http://thewaltdisneynut.com/parks/magickingdom/adventureland/tikiroom.php');
} elseif ($location == "adventureland" && $attraction == "nedsboats") {
include('http://thewaltdisneynut.com/parks/magickingdom/adventureland/nedsboats.php');
} elseif ($location == "adventureland" && $eatsshops == "main") {
include('http://thewaltdisneynut.com/parks/magickingdom/adventureland/eatsshops.php');

} elseif ($location == "frontierland" && $attraction == "bigthundermountain") {
include('http://thewaltdisneynut.com/parks/magickingdom/frontierland/bigthunder.php');

and so on and so on.

That works fine, so I thought I would use the same code, changed slightly, to change the title for each page. Well, it doesn't work. (This is actually in header.php, included in magickingdom.php):

if ($location == "" && $attraction == "") {
$title = "TheWaltDisneyNut.com - Theme Parks - Magic Kingdom";
} elseif ($location == "mainstreet" && $attraction == "") {
$title = "TheWaltDisneyNut.com - Theme Parks - Magic Kingdom - Main Street USA";
} elseif ($location == "adventureland" && $attraction == "") {
$title = "TheWaltDisneyNut.com - Theme Parks - Magic Kingdom - Adventureland";
} elseif ($location == "frontierland" && $attraction == "") {
$title = "TheWaltDisneyNut.com - Theme Parks - Magic Kingdom - Frontierland";
} elseif ($location == "libertysquare" && $attraction == "") {
$title = "TheWaltDisneyNut.com - Theme Parks - Magic Kingdom - Liberty Square";
} elseif ($location == "fantasyland" && $attraction == "") {
$title = "TheWaltDisneyNut.com - Theme Parks - Magic Kingdom - Fantasyland";
} elseif ($location == "toontown" && $attraction == "") {
$title = "TheWaltDisneyNut.com - Theme Parks - Magic Kingdom - Toon Town";
} elseif ($location == "tomorrowland" && $attraction == "") {
$title = "TheWaltDisneyNut.com - Theme Parks - Magic Kingdom - Tomorrowland";

} elseif ($location == "adventureland" && $attraction == "junglecruise") {
$title = "TheWaltDisneyNut.com - Theme Parks - Magic Kingdom - Adventureland - Jungle Cruise";
} elseif ($location == "adventureland" && $attraction == "pirates") {
$title = "TheWaltDisneyNut.com - Theme Parks - Magic Kingdom - Adventureland - Pirates of the Caribbean";
} elseif ($location == "adventureland" && $attraction == "treehouse") {
$title = "TheWaltDisneyNut.com - Theme Parks - Magic Kingdom - Adventureland - Swiss Family Treehouse";
} elseif ($location == "adventureland" && $attraction == "aladdin") {
$title = "TheWaltDisneyNut.com - Theme Parks - Magic Kingdom - Adventureland - Magic Carpets of Aladdin";
} elseif ($location == "adventureland" && $attraction == "tikiroom") {
$title = "TheWaltDisneyNut.com - Theme Parks - Magic Kingdom - Adventureland - The Enchanted Tiki Room";
} elseif ($location == "adventureland" && $attraction == "nedsboats") {
$title = "TheWaltDisneyNut.com - Theme Parks - Magic Kingdom - Adventureland - Shrunken Ned's Jungle Boats";
} elseif ($location == "adventureland" && $eatsshops == "main") {
$title = "TheWaltDisneyNut.com - Theme Parks - Magic Kingdom - Adventureland - Eats & Shops";

} elseif ($location == "frontierland" && $attraction == "bigthundermountain") {
$title = "TheWaltDisneyNut.com - Theme Parks - Magic Kingdom - Frontierland - Big Thunder Mountain";

and so on and so on.

<title> <?php echo $title?> </title>

It only shows the very first one (TheWaltDisneyNut.com - Theme Parks - Magic Kingdom), regardless of what page I'm on. Why isn't this working?
Reply with Quote Reply
Feb 26th 2002#33168 Report
Member since: Mar 20th 2001
Posts: 3367
use case statements instead....

switch($page) {

case "location" : $title = "title here"; $pagesource; break;
case "location" : $title = "title here"; $pagesource; break;


}

then on the page itself..

<.title>


or as how u want it too... I used this method for one of my previous versions of my site
Reply with Quote Reply
Feb 26th 2002#33172 Report
Member since: Mar 18th 2001
Posts: 1452
Ok, I don't really get switch\case statements. I did a search, and still don't get them. At least not for what I need to do.

I need to recognize more than just 'location', the way my links/page(s) are set up.

Three actual examples:

If the page is:
http://thewaltdisneynut.com/magickingdom.php

I need it to say:
TheWaltDisneyNut.com - Theme Parks - Magic Kingdom

If the page is:
http://thewaltdisneynut.com/magickingdom.php?location=adventureland

I need it to say:
TheWaltDisneyNut.com - Theme Parks - Magic Kingdom - Adventureland

And if the page is:
http://thewaltdisneynut.com/magickingdom.php?location=adventureland&attraction=pirates

I need it to say:
TheWaltDisneyNut.com - Theme Parks - Magic Kingdom - Adventureland - Pirates of the Caribbean

So I need to recognize if there is no location or attraction, if there is a location but no attraction, and if there is a location and attraction.
Reply with Quote Reply
Feb 26th 2002#33176 Report
Member since: Mar 20th 2001
Posts: 3367
Andrew... Need help here... :D
Reply with Quote Reply
Feb 26th 2002#33177 Report
Member since: Mar 20th 2001
Posts: 3367
err.. <.?php echo $title ;?.> the ";"

i don't know if that affects the code...

i'm quite busy.. that switch/case is the one i'd recommend.. see what Andrew comes out with...
Reply with Quote Reply
Feb 28th 2002#33562 Report
Member since: Jun 30th 2001
Posts: 447
Let me see if I get this straight... you call header.php then you have your if/else statements. Right? If so, the $title variable won't be set because you're calling header.php before you're setting the title. IMO, you're better off creating two database tables, locations and attractions, with a common key. This will save you a mess later on even if it does seem like a lot of work now.
Reply with Quote Reply
Feb 28th 2002#33574 Report
Member since: Mar 18th 2001
Posts: 1452
This is my header.php (more or less). It's the first thing called.

<html>

<head>

<?php
if blah
$title = blah
elseif blah
$title = blah
?>

<title> <?php echo $title?> </title>

</head>

I'm declaring the $title variable(s) before the call. Wouldn't that be right?

I did this once before and it worked, but it was simple ?page=whatever. It doesn't seem to work with all those extras.
Reply with Quote Reply
Page: 1 Back to top
Please login or register above to post in this forum