Jump to content
xisto Community
Sign in to follow this  
Prophet.K

Php Auto Website Title

Recommended Posts

This simple PHP function is pretty handy if you want your websites pages in the title without having to name individual ones.

It will look like:

MyWebsite | Index

Quote:MyWebsite | Gallery


Quote:MyWebsite | Forums

etc..

paste the code into your "functions" file, or any webpage which is included in every page you have
(Reminder: To include a webpage, use 'include("webpage.php");')
You can of course put the function in each page, but that's just annoying .. :lol:

then, in each webpage you want the title to appear, put

Code:<?phpinclude("the_function_webpage");title();....
?>


I've quoted each line to show the people who don't do PHP, how the function works a little better

function title() {  $page = $_SERVER["PHP_SELF"];  // Set variable $page as the current webpage  $page = str_replace(".php","",$page);  // Remove the .php ending from the string: $page  $page = str_replace("/","",$page);  // Remove the / before the website name  $page = ucwords($page);  // Capitalize the first letters  echo '<title>MyWebsite | ' .$page. '</title>';  // Change "MyWebsite" to your website name}

Share this post


Link to post
Share on other sites

Very helpful! I think u you shoulda posted it under how-tos. Anyway I thank you for such info.I wanted to ask if u know how I can inset that small icon that appears in the browser on the address bar. I want my site to display such a thing. Help! Anybody?

Share this post


Link to post
Share on other sites

Very helpful! I think u you shoulda posted it under how-tos. Anyway I thank you for such info.I wanted to ask if u know how I can inset that small icon that appears in the browser on the address bar. I want my site to display such a thing. Help! Anybody?


Always wondered the same thing! Will now do one for site i'm currently building. Not a php thing tho.

http://www.chami.com/tips/internet/110599I.html

and the same 16x16 icon can be displayed when user bookmarks you page, apparantly :D

http://forums.xisto.com/no_longer_exists/

Share this post


Link to post
Share on other sites

lol I was usually either writing it to every different page or just using some get variable since sometimes I build sites that are accessible only trough index and then when they in fact click on the link link looks something like this index.php?page=about so it initializes variable page with the name content about and you are able to access any page you wuild with this also variable is accessible trough $_GET['page'] simple as that.But in the end I must admit your solution is a lot more elegant. However I see that there might be some problems if one page is include in the other one and is also accessible on its self. And one other problem is if you have php files name in different way then the paeg names. Also what happenes when you've got there get variables I think that it gots distorted. Well these are just thoughts someone might shed some light on it. best regards

Share this post


Link to post
Share on other sites

yea, i have used a small icon for favorites menus, you need to create an icon, 16x16 px.
Then you have to upload it somewhere, and in some cases, create a CSS file to tell the browser where to find the file.
I cant remember how to do it exactly, google it, there areseveral tutoials on how to do it...

I wanted to ask if u know how I can inset that small icon that appears in the browser on the address bar. I want my site to display such a thing. Help! Anybody?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.