5, December 2008

Is this possible? (automated browser title) - webmaster forum

 
Webdigity webmaster forums
This forum shares its ad revenue with its members!
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: Is this possible? (automated browser title)
« previous next »
Pages: [1] Print

Author Topic: Is this possible? (automated browser title)  (Read 647 times)
I crack Photoshop!
*
Posts: 3
30 credits
Members referred : 0



« on: Oct 07, 2007, 03:14:17 PM »

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!
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 884
1636 credits
Members referred : 4



« Reply #1 on: Oct 07, 2007, 04:05:29 PM »

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

Visit through proxy Visit through proxy Visit through proxy

Last blog : phpHaze 1.59.1 in Development
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8272
42619 credits
Members referred : 3



« Reply #2 on: Oct 07, 2007, 10:59:17 PM »

That's correct, but you will have to use $_SERVER['REQUEST_URI'] instead of PHP_SELF if those urls are mod_rewrited

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy or twitter Visit through proxy

Last blog : Free Unlimited Bandwith and disk space to good to be true?
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 884
1636 credits
Members referred : 4



« Reply #3 on: Oct 08, 2007, 07:15:36 AM »

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

Visit through proxy Visit through proxy Visit through proxy

Last blog : phpHaze 1.59.1 in Development
Pinoy Webmaster
.com pimp
*****
Gender: Male
Posts: 1126
6048 credits
Members referred : 0


Philippine Beaches


« Reply #4 on: Oct 08, 2007, 09:43:20 AM »

thanks for the share!


Last blog : Santiago Beach, Cebu, Philippines
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8272
42619 credits
Members referred : 3



« Reply #5 on: Oct 08, 2007, 01:39:19 PM »

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>";
}



Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy or twitter Visit through proxy

Last blog : Free Unlimited Bandwith and disk space to good to be true?
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 884
1636 credits
Members referred : 4



« Reply #6 on: Oct 08, 2007, 08:22:26 PM »

ah oops, left out the 2nd use of request_uri, my mistake! Cheesy

Visit through proxy Visit through proxy Visit through proxy

Last blog : phpHaze 1.59.1 in Development
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=7196
Tags : Is this possible? (automated browser title) Bookmark this thread : Digg Del.icio.us Dzone more....

Topic sponsors:
Get a permanent link here for $1.99!


Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: Is this possible? (automated browser title)
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
Dec 05, 2008, 02:57:39 AM





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!


Forum Statistics
Total Posts: 37.995
Total Topics: 7.685
Total Members: 4.467
Tutorials : 56
Resources : 143
Designs : 220
Latest Member: jschless81

25 Guests, 3 Users online :

10 users online today:



Readers

Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2008 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.