need some help<

liunx

Guest
Ok, im not so good with PHP so don't beat me.

Basically im using functions to do the layout, so i can have the whole layout in 1 file, but i want to have different titles (along the top, e.g. it says HTMLForums along the top) but having title in the funtcions file, its gonna be the same on every page. So i was thinking if you have a file called About.php, maybe you could put the title as About, or if you have a file called Members.php, the title would be Members, and so on, i was looking for some advice on how to achieve this. Or maybe a script on how to do this ;)'lo Mike........

some of the methods expressed here to deal with keywords could help you in regards to the title since it is a similar sort of problem:

<!-- m --><a class="postlink" href="http://www.htmlforums.com/showthread.php?s=&threadid=27823">http://www.htmlforums.com/showthread.ph ... adid=27823</a><!-- m -->

might help....if not I'm sure someone else can point you in the right direction.If you're using only one file for the layout, I assume that you decide what content to show using the query string.

index.php?page=About

Or something similar. I suppose you then check what this variable is equal to, and include a page.

if($_GET['page'] == 'About'){
include("About.php");
}

If this is how you're doing it, you can just do the same thing at the top of your script, but inserting the appropriate title, instead of including another page.

if($_GET['page'] == 'About'){
echo "<title>About</title>";
}

Or something along those lines... I'm not sure I understood this correctly. Maybe it helps..i was thinking a bit about it and made this


<?php

$title = explode(".", $_SERVER['PHP_SELF']);

?>

<HTML>
<HEAD>
<TITLE><?php echo $title[0] ?></TITLE>
</HEAD>
<BODY>
<?php echo $title[0] ?
</BODY>
</HTML>


the bad thing is tho, its places a / infront of the word because thats what php_self does, and i cant figure out how to get rid of it....

digitalgot it!

<?php

list($title, $ext) = explode(".", $_SERVER['PHP_SELF']);
unset($ext);
$title = substr($title, 1);

?>

<HTML>
<HEAD>
<TITLE><?php echo $title ?></TITLE>
</HEAD>
<BODY>
<?php echo $title ?>
</BODY>
</HTML>


thats will make test.php - test, hello.php - hello, home.php - home, etc etc, :D
 
Back
Top