CodeIgniter Forums
how dynamic titles - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: how dynamic titles (/showthread.php?tid=66965)



how dynamic titles - carloz360 - 12-23-2016

How can I show dynamic titles for my application posts? I already red the docs. But I cant achive that for exampe I created a blog but in every post does not change the title. I wrote this config['page_title'] = "my title", but that title is showing in every post.


RE: how dynamic titles - Wouter60 - 12-24-2016

Make sure the page title is in the data array your controller passes to the view.
PHP Code:
$data['page_title'] = 'The title of this page' //assign dynamically
$this->load->view('post-view-file',$data); 

In the head section of your view (or the header part of your template:
PHP Code:
<head>
 
 <title>
 
    <?php if (!empty($page_title)) echo $page_title;?>
  </title>
</head> 



RE: how dynamic titles - carloz360 - 12-24-2016

(12-24-2016, 01:12 AM)Wouter60 Wrote: Make sure the page title is in the data array your controller passes to the view.
PHP Code:
$data['page_title'] = 'The title of this page' //assign dynamically
$this->load->view('post-view-file',$data); 

In the head section of your view (or the header part of your template:
PHP Code:
<head>
 
 <title>
 
    <?php if (!empty($page_title)) echo $page_title;?>
  </title>
</head> 

Thanks for the response I already did that. But I want that title to change on every post dynamically for exemple im creating this movie review blog but when i go in every movie the title does not change. http://blog.codigero.com/


RE: how dynamic titles - enlivenapp - 12-24-2016

You haven't given us much to go on.  If you have the field 'movie_title' in your database table you can do something like:

PHP Code:
// pseudo-code
$result $query->row_array();

$data['page_title'] = $result['movie_title'];
$this->load->view('post-view-file'$data); 

 then continue with Wouter60's answer.

If you need more specific help, you'll need to post your code.


RE: how dynamic titles - carloz360 - 12-24-2016

(12-24-2016, 07:39 AM)enlivenapp Wrote: You haven't given us much to go on.  If you have the field 'movie_title' in your database table you can do something like:

PHP Code:
// pseudo-code
$result $query->row_array();

$data['page_title'] = $result['movie_title'];
$this->load->view('post-view-file'$data); 

 then continue with Wouter60's answer.

If you need more specific help, you'll need to post your code.

Thanks enlivenapp !! it works...