28, May 2012

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

 
Webdigity webmaster forums
[ 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
Instabuck - The easy way to sell digital products online

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



« on: Oct 07, 2007, 02: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: 886
1148 credits
Members referred : 4



« Reply #1 on: Oct 07, 2007, 03:05:29 pm »

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


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



« Reply #2 on: Oct 07, 2007, 09: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 or twitter

Last blog : Butterfly Marketing 2.0
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 886
1148 credits
Members referred : 4



« Reply #3 on: Oct 08, 2007, 06: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


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, 08:43:20 am »

thanks for the share!


Last blog : Bingag Beach, Bohol, Philippines
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #5 on: Oct 08, 2007, 12: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 or twitter

Last blog : Butterfly Marketing 2.0
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 886
1148 credits
Members referred : 4



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

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


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....

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?
May 28, 2012, 09:30:11 pm





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!






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