Hello, im trying to make the CMS system im using more SEO friendly by giving each page it's own title. Right now, the system assigns all pages the same general title. I would like to use PHP to discertain which page is being viewed and in turn, which title should be used. I have put in the title tags the variable "$title". As for the PHP im using, I scripted the following: $url = "http://'.$_SERVER['SERVER_NAME']''.$_SERVER['REQUEST_URI']'"; switch ( $url ) { default: $title = "Photoshop tutorials, Flash tutorials, and more! Newtuts Tutorial Search"; break; case "$config[HTTP_SERVER]help.php" : $title = "Newtuts Help"; break; } PHP: Right now, im getting this error: Can someone please help me with this?
Try this: $url = "http://{$_SERVER['SERVER_NAME']}{$_SERVER['REQUEST_URI']}"; switch ( $url ) { case "{$config['HTTP_SERVER']}help.php" : $title = "Newtuts Help"; break; default : $title = "Photoshop tutorials, Flash tutorials, and more! Newtuts Tutorial Search"; } Code (php):
Im not getting anymore errors, but its still not working. You can see the site im trying to implement this on here: http://www.newtuts.com
<title>echo $title</title> Can you post the php-code you use to echo out the $title-var? i.e <title><?php ... ?></title>
<title>echo $title</title> ... where is ";" ?? <title>echo $tilte;</title> if it does not work try to close PHP tag "?>" before tiltle tag then try this <title><?php echo $title; ?></title> i only know this, I m a beginner
Now were getting somewhere! The title is now being displayed as the web page URL. Now we just need to get it to recognize the URL, and assign an actual title. Any ideas?
may be easier to just put a "title" column in your database put your query at the top.. for each page put this line in the <head> section: echo "<title>$row[title]</title>";
I thought about that, but im using a CMS system, and Im afraid that if I do that it will mess something up. There are very few custom pages that I will need titles for, so I would rather do things the way I had originally planned if possible.
Looks like I am late to the party. I am going to back up and ask a couple of questions: Which CMS system are you using? (Could influence approach). Does the CMS system use Smarty or other template engine? Are you currently using the Apache URL Rewrite module?
Lol, im just glad you came 1. I am using a modified system of TutorialMS 2. It uses a custom template engine. Basically it includes the config and global files on every page, and then, depending on the page, it includes from the database the right page info. 3. I am not using any rewrite modules.
It appears the title is set and stored in a global variable $glob['title']. The page titles follow the pattern below (do you want to modify the highlighted title?): $glob['title'] = COMPANY_NAME.' - Index'; $glob['title'] = COMPANY_NAME.' - Contact Us'; $glob['title'] = COMPANY_NAME.' - Help'; $glob['title'] = COMPANY_NAME.' - '.$read_tutorial['title']; $glob['title'] = COMPANY_NAME.' - Submit Tutorials'; $glob['title'] = COMPANY_NAME.' - Tutorials from '.$glob['sourcesite']; $glob['title'] = COMPANY_NAME.' - Submit Tutorials'; $glob['title'] = COMPANY_NAME.' - Browse Tutorials'; $glob['title'] = COMPANY_NAME.' - '.$glob['cur_cat_name'].' - All'; $glob['title'] = COMPANY_NAME.' - '.$glob['cur_cat_name'].' - '.$glob['cur_sub_name']; $glob['title'] = COMPANY_NAME.' - '.$user['username'].'\'s Profile Page'; $glob['title'] = COMPANY_NAME.' - Register'; $glob['title'] = COMPANY_NAME.' - '.$glob['tutorial_out_title']; $glob['title'] = COMPANY_NAME;
This doesnt seem right. Before I tried setting a dynamic title. The same title was displayed for everything. Why is this?
I am using TutorialMS 1.4 as the baseline. Are you using a different version or have you modified the original title algorithm?