Cantroller
public function category() {
//Get Article View
$data['categories'] = $this->Article_model->get_categories_f('id','DESC');
//Get Articles
$data['articles'] = $this->Article_model->get_articles('id','DESC');
//Load View
$this->load->view('cat', $data);
}
Models
public function get_categories_f($order_by = null, $sort = 'DESC', $limit = null, $offset = 0) {
$this->db->select('*');
$this->db->from('categories');
if($limit != null) {
$this->db->limit($limit, $offset);
}
if($order_by != null) {
$this->db->order_by($order_by, $sort);
}
$query = $this->db->get();
return $query->result();
}
View
<?php foreach ($articles as $article) : ?>
<span class="head-title"><?php echo $article->category_name; ?></span>
<?php endforeach; ?>
Problem Is Display All categories post on view not for only selected category please help me for this
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.