Welcome Guest, Not a member yet? Register   Sign In
Set page title from DB value
#1

[eluser]razputin[/eluser]
I use $data['title'] to set the page title and I'm looking for a way to change the title based on the page content.
Is it possible to assign an element in a data array to another? Something like this (doesn't work):

Code:
$data['article']=$this->article_model->get_article($article_id);
$data['title']=$data['article']['title'];

Or is there a better approach to set the page title dynamically?
#2

[eluser]Eduard Stankovic[/eluser]
what is your code of Article_model::get_article() ?

are you returning result_array() or row_array() ?
#3

[eluser]razputin[/eluser]
It's row_array()

from model:

Code:
function get_article($article_id)
{

$query = $this->db->get_where('articles', array('id' => $article_id));
  return $query->row_array();
}
#4

[eluser]CroNiX[/eluser]
Code:
$data['article']=$this->article_model->get_article($article_id);

in view
Code:
echo $article['title'];

no need to pass it 2x




Theme © iAndrew 2016 - Forum software by © MyBB