ivanna Posted January 20, 2011 Share Posted January 20, 2011 Hello, I am assigned a task to make alterations on a client website. The header is an include on all pages. Inside the header is the title tag which propogate to all pages. I want title different to each page, I will also add description and keyword. Is there a way to do this with PHP or should I have different header for each page. thank you Quote Link to comment https://forums.phpfreaks.com/topic/225129-how-can-i-add-different-title/ Share on other sites More sharing options...
Maq Posted January 20, 2011 Share Posted January 20, 2011 Sure, there are multiple ways of doing this depending on your structure. You can look at the page (URI), send a command for whatever page you're directing to etc. Again, it depends on your structure, specifically how you navigate through each section. Quote Link to comment https://forums.phpfreaks.com/topic/225129-how-can-i-add-different-title/#findComment-1162775 Share on other sites More sharing options...
Jocka Posted January 21, 2011 Share Posted January 21, 2011 Well is the header page that is included, a php file? If so just do something like <title><? echo $title; ?></title> then before including it just set the title: $title = "SITENAME - Pagename"; etc, u get the point. Quote Link to comment https://forums.phpfreaks.com/topic/225129-how-can-i-add-different-title/#findComment-1162786 Share on other sites More sharing options...
ivanna Posted January 21, 2011 Author Share Posted January 21, 2011 Thank you for your replies. Maq, the site is small and navigation is a list in the header. Jocka, the header page is header.php I am to understand in header.php I add <title><? echo $title; ?></title> and on each page I add $title = "SITENAME - Pagename"; where pagename is the page being accessed. I add this before the include. Would it be correct to add description and keywords the same way?? Thank you for this help. Quote Link to comment https://forums.phpfreaks.com/topic/225129-how-can-i-add-different-title/#findComment-1163109 Share on other sites More sharing options...
Pikachu2000 Posted January 21, 2011 Share Posted January 21, 2011 Don't get in the habit of using short <? open tags, use the full <?php open tag syntax. Anyhow, yes you can add whatever you'd like to add by echoing it into the html markup. Quote Link to comment https://forums.phpfreaks.com/topic/225129-how-can-i-add-different-title/#findComment-1163167 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.