Page name changed by links to determine content

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
mcallinder
Forum Newbie
Posts: 3
Joined: Wed Feb 02, 2011 2:36 pm

Page name changed by links to determine content

Post by mcallinder »

Hello all!

I am trying to figure out how to change the name of a page by clicking on a link. I want to have one main page (index) that has my header, content, and footer. I want the content of the page to change depending on what link is clicked. Currently, I have it set up so that each content page has a name, an include for the header, the respective content, and an include for the footer. My navigation is on the header page with certain links and info changing depending on the name of the content page.

Basically I want to do the reverse of this so that my header and footer is on one index page which is calling the content from other files. I've been trying to write a code that changes the name of the page depending on which content you are viewing (active link) so then I can do something like:

Code: Select all

<?php $thisPage="Page Name Here"; ?> <-- this is what I want the active link to change

<head>
<title><?php if ($thisPage!="") echo "$thisPage"; ?></title>
</head>

<body>
Navgation etc

<?php if ($thisPage=="Page Name Here") include("content.php"); ?> 
OR
<?php if ($thisPage=="Page Name Here") echo ' Content Here '; ?>

Footer etc
</body>
Any ideas?
User avatar
Jade
Forum Regular
Posts: 908
Joined: Sun Dec 29, 2002 5:40 pm
Location: VA

Re: Page name changed by links to determine content

Post by Jade »

Code: Select all

<?php $thisPage=$_GET['page']; ?> <-- this is what I want the active link to change

<head>
<title><?php if ($thisPage!="") echo "$thisPage"; ?></title>
</head>

<body>
Navgation etc
<a href="?page=news">News</a> | <a href="?page=forum">News</a> | 

<?php
//you'd need to do a check here to make sure $thisPage was valid but then you can
//include the content based on the value of the variable.
include($thisPage . ".php");
?>

Footer etc
</body>
 
Post Reply