[eluser]Unknown[/eluser]
My Function get navigation
Code:
public function get_navigation_header(){
$result = array();
$result = $this->array_category();
foreach($result as $key=>$val){
$result[$key]['submenu'] = $this->array_category($result[$key]['id']);
$result[$key]['news'] = $this->hotnew_category($result[$key]['id']);
}
return $result;
}
Get news in here
Code:
$result[$key]['news'] = $this->hotnew_category($result[$key]['id']);
This is function get news
Code:
public function hotnew_category($id){
$this->db->select('id,name,image,created,content,summary');
$this->db->limit(3);
$this->db->where('cat',$id);
$this->db->order_by('created','DESC');
$data = $this->db->get(TABN);
$news = $data->result_array();
foreach($news as $key=>$val){
$news[$key]['link'] = $this->linkNew($news[$key]['id']);
$news[$key]['image'] = $this->tungphut->get_image_instead($news[$key]['image'],$news[$key]['content']);
}
return $news;
}
This is function get link for a new
Code:
public function linkNew($id){
$this->db->select('id,cat,rewrite');
$this->db->where('id',$id);
$data = $this->db->get(TABN);
$new = $data->row_array();
$url = $new['rewrite'].'.html';
$this->db->where('id',$new['cat']);
$data = $this->db->get(TABCAT);
$category = $data->row_array();
$url = $this->hasParent($category['parent'],$category['rewrite']).$url;
$url = base_url($url);
return $url;
}
public function hasParent($parent,$rewrite){
$url = '';
if($parent == 0){
$url = $rewrite.'/';
}
else {
$this->db->where('id',$parent);
$data = $this->db->get(TABCAT);
$category = $data->row_array();
$url = $this->hasParent($category['parent'],$category['rewrite']).$rewrite.'/';
}
return $url;
}