[PHP] Dynamic Titles
Hello, im trying to make the CMS system im using more SEO friendly by giving each page it's own title. Right now, the system assigns all pages the same general title. I would like to use PHP to discertain which page is being viewed and in turn, which title should be used. I have put in the title tags the variable $title. As for the PHP im using, I scripted the following: $url = http://'.$_SERVER['SERVER_NAME']''.$_SERVER['REQUEST_URI']'; switch ( $url ) { default: $title = Photoshop tutorials, Flash tutorials, and more! Newtuts Tutorial Search; break; case $config[HTTP_SERVER]help.php : $title = Newtuts Help; break; } Right now, im getting this error: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/a7201901/public_html/includes/classes/tutorial.php on line 803 Can someone please help me with this? Thanks!
Re: [PHP] Dynamic titles.
You can split $_SERVER['REQUEST_URI'] on the /'s to get the directories, eg: http://site.com/info/your_pet/dogs/page.html would result in /dir/anotherdir/page.php So, (untested code): ? $title = 'Name of My Site'; $urlBits = explode('/',$_SERVER['REQUEST_URI']); $i = 0; foreach($urlBits as $bit) { $i++; if($i count($urlBits) !empty($bit)) { $bit = str_replace('_', ' ', $bit); $bit = ucwords($bit); $title .= / {$bit} ; } } echo $title; ? Should echo something like: 'Name of My Site / Info / Your Pets / Dogs' All you need to to do is echo $title in the title tag, and season to taste :) Justin on 14/03/03 4:44 AM, Sebastian ([EMAIL PROTECTED]) wrote: Hello. I have many pages, and was thinking of a way to generate dynamic page titles, very similar to a breadcrumb where it uses the directory structure to make the page title. Anyone have something like this, and is willing to give a hand? warm regards, Sebastian - [BBR] Gaming Clan http://www.broadbandreports.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Dynamic titles.
Hello. I have many pages, and was thinking of a way to generate dynamic page titles, very similar to a breadcrumb where it uses the directory structure to make the page title. Anyone have something like this, and is willing to give a hand? warm regards, Sebastian - [BBR] Gaming Clan http://www.broadbandreports.com