CodeIgniter Forums

Full Version: Different Meta Title for each Page
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

I am very new with CodeIgniter and I am having difficulty in making few things work. I want to have different meta title for each static pages and dynamic pages. Below is the code which I am using for meta title.

<?php if($title){ echo $title.' - '; } ?><?php echo $settings->sitename;?>

I want to echo $title only on dynamic page and sitename to other pages like home, about and contact us. Is there any way to do it by using if else Statements?

El Forum

Firstly, if you want any kind of traffic from the search engines, you don't want to just echo "sitename", you really should have meaningful titles like "Contact Us" (or Contact "sitename").

Even if you don't want search engine traffic remember that the title displays on the browser tabs, so if it's for an intranet or something you still want something meaningful for the users of the site.

As for your question "Is there any way to do it by using if else Statements?", if your static pages do NOT have a $title (aka $data['title']) set in them then it's an easy

if(isset($title) && $title != ''){
   // echo your title
  // echo your sitename