unique title, meta keyword, meta description for each page? how to

i’ve been handed a completed site that the client now wants to
1. have unique title, meta keyword, meta description for each page.

right now it just looks like the View is calling a Header that has the title, meta keyword, meta description coded right into it (so it's the same on every single page of the site).

Can someone push me in the right direction on what i need to do here? ps. i have no idea what version of codeigniter this site was built on .


Its just matter of defining the title etc. in the controller for the specific pages. If content is coming from database, you should add title, description and keywords fields to the pages table.

If you have static pages(not coming from db) adding title, keywords and description should be simple like this:

Controller About
class About extends Controller {

    function About()
    function index()
        $data['title'] = 'About title';
        $data['keywords'] = 'some,keywords,here';
        $data['description'] = 'Snakeoil ltd. The best oil in the business';

header view
&lt;title&gt;&lt;?php echo $title ?&gt;&lt;/title&gt;
&lt;meta name="description" content="&lt;?php echo $description ?&gt;"&gt;
&lt;meta name="keywords" content="&lt;?php echo $keywords ?&gt;"&gt;

In the controller theres $this->load->vars($data) which will make $data['title'] shown as $title, $data['description'] shown as $description etc. in all views including header view.

You could also send the $data array to the header view:

Either way will do.

the content is coming from a database (there are several hundred "pages"). more info would be helpful, but what you've told me is great. I think i can do this now.

...heh snakeoil

For example (quick and dirty);

the Model

function get_content($id) {
        $this->db->where('id', $id);
        $query = $this->db->get('content', 1);
        if ($query->num_rows() == 1) {
           $row = $query->row();
           return $row->text;

the controller

function index() {
        $id = '32';
        $data['page_title'] = $this->content_model->get_content($id);
        $this->load->view('page', $data);

the view

echo $page_title

Thanks i got this working...

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.