View Full Version : Is this possible? (automated browser title)

09-25-2007, 11:22 PM
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?

09-25-2007, 11:52 PM
yse this is possible and there are tutorials out there, perhaps I am reading a book that i bought and it shows how do do that,

If you are think as the browser title page like

<title>Welcome to atari2600</title> <<<like that

and have pages show up like

<title>Welcome to atari2600 - about</title>

something like that, sorry... I might be able to post the tutorial,
but try searching in google
php titles tutorials

or something with those keywords and it might help....

It has something to do with


09-26-2007, 12:53 PM
$a = explode('/',$_SERVER['PHP_SELF']);
$a = implode(' > ',$a);

Probably close. Some reworking is possible.

09-27-2007, 03:46 AM
actually i found the code.....

In the title tags put this...

<title> Roboto<?php echo "—{$title}"; ?> </title>

Include this file in the same page.

$title = basename($_SERVER['SCRIPT_NAME'], '.php';
$title = str_replace('_', ' ', $title);
$title = ucwords($title);

So there it is... I will tell you what it does to..

The first line tells you to get the the name and take it and kill the .php.
The second line takes the name of the title and takes out all the "_" and replaces them with a space.
The third line takes the title and (ucwords) meaning uppercase words, witch makes them capitalized..

Hope this works for you!

09-27-2007, 11:52 AM
basename defeats the point. the OP wanted to have the directory displayed as levels in the title.

09-27-2007, 03:13 PM
hahah then I have no freakin clue.... srry