Sublime directory Surf the web anonymous Pagerank Monitor


Is this possible? (automated browser title)

Mosqwik
Sun 7 October 2007, 02:14 pm GMT +0200
Hi,
Something that would be really useful for a new project im working on would be to have automated browser titles using some php code in the <title> tags.
The only way I can think of doing this is by having the php code read the url im using for navigation, e.g. /windows/atari2600/ and use that data, edit it and have it display as 'Windows > Atari 2600'
Has this kind of thing been done before? are there any other common ways of doing this? Also are there any tutorials around?
Thanks!

Meth0d
Sun 7 October 2007, 03:05 pm GMT +0200
if (strpos($_SERVER['PHP_SELF'], "/") === TRUE){
      $title explode("/"$_SERVER['PHP_SELF']);
      echo "<title>Site Name: ".$title[1]." &gt; ".$title[2]."</title>";
}
?>

Nikolas
Sun 7 October 2007, 09:59 pm GMT +0200
That's correct, but you will have to use $_SERVER['REQUEST_URI'] instead of PHP_SELF if those urls are mod_rewrited

Meth0d
Mon 8 October 2007, 06:15 am GMT +0200
thanks for the tip Nik, here is some rewritten, much nicer code

if (strpos($_SERVER['REQUEST_URI'], "/") === TRUE){
      
$title explode("/"$_SERVER['PHP_SELF']);
      echo 
"<title>Site Name: ".ucwords($title[1])." &gt; ".ucwords($title[2])."</title>";
}
?>


i changed it to REQUEST_URI, but user can change back if wish... and i added "ucwords" to capitalize the first word in each returned value.. just to show some simple usage of dynamic naming

vbignacio
Mon 8 October 2007, 08:43 am GMT +0200
thanks for the share!

Nikolas
Mon 8 October 2007, 12:39 pm GMT +0200
Still needs some correction. Here is the correct one :

if (strpos($_SERVER['REQUEST_URI'], "/") === TRUE){
      
$title explode("/"$_SERVER['REQUEST_URI']);
      echo 
"<title>Site Name: ".ucwords($title[1])." &gt; ".ucwords($title[2])."</title>";
}
?>



Meth0d
Mon 8 October 2007, 07:22 pm GMT +0200
ah oops, left out the 2nd use of request_uri, my mistake! :D

Archive for SMF v1.00 by N.P. Valid XHTML 1.0 Transitional