Im a designer that i´m taking my first steps on the programing área, mostly on PHP / MySQL. Past week i need to add a blog section on a page made with code igniter.
I make the secction that show all post in order (title and published date). I made a view that takes the id to show the content. But i can`t echo any of the variables.
When i use var_dump or print and it takes all the variables without any problem.
Did i miss somehting? :(
Thank you.
Model:
class blog extends CI_Model {
public function get($id){
$this->db->select('id, title, description, icon, uri, published_at');
$this->db->from('blogs');
$this->db->where('id', $id);
$query = $this->db->get();
$data = $query->result();
return $query->result();
if(!empty($data)){
return $this->make_groups($data);
}
}
}
Controller:
Class Pages extends CI_Controller {
public function blog_detail($id) {
$this->load->model('blog');
if($data = $this->blog->get($id)) {
$this->load->model('blog');
$this->data['blog_menu'] = TRUE;
$this->data['blog'] = $data;
$this->data['og'] = array(
'description' => 'INFO',
'image' => site_url('assets/images/og/blog.png')
);
# layout config
$this->layout->add_css(site_url('assets/css/blog.css'));
$this->layout->title_for_layout = "TITLE";
$this->layout->meta = array(
array('name' => 'description', 'content' => 'DETAIL'),
array('name' => 'keywords', 'content' => 'KEYWORDS'),
);
$this->layout->render('pages/blog_detail/index', $this->data);
}
}
}
View:
<?php var_dump($this->data);
echo $blog->published_at; ?>