three lavel category link

0
627

<?php echo form_open(‘products’,’id=”srcfrm” name=”srcfrm”‘);
if($this->uri->rsegment(1)==”category” && $this->uri->rsegment(2)==”index” ){
$cid = $this->uri->rsegment(3); ?>
<input type=”hidden” name=”category_id” id=”category_id” value=”<?php echo $this->uri->rsegment(3);?>” /><?php
}else{ $cid = $this->input->post(‘category_id’); ?>
<input type=”hidden” name=”category_id” id=”category_id” value=”<?php echo $this->input->post(‘category_id’);?>” />
<?php
}?>
<?php echo form_close();
$curr_symbol = display_symbol();
$condtion_array = array(
‘field’ =>”*,( SELECT COUNT(category_id) FROM wl_categories AS b
WHERE b.parent_id=a.category_id ) AS total_subcategories”,
‘condition’=>”AND parent_id = ‘0’ AND status=’1′ “,
‘limit’=>20,
‘order’=>’sort_order’,
‘offset’=>0,
‘debug’=>FALSE
);
$res = $this->category_model->getcategory($condtion_array);
if(is_array($res) && !empty($res) ){
echo “<ul>”;
foreach($res as $val){
$total_subcategories = $val[‘total_subcategories’];
if($total_subcategories>0){
$link_url = base_url().$val[‘friendly_url’];
}else {
$link_url = base_url().$val[‘friendly_url’];
}
if($total_subcategories>0){
$hrefval=”#”;
$clls=”dd_next1″;
}
else {
$hrefval = base_url().$val[‘friendly_url’];
$clls=””;
}

?>

<li><span><i class=”<?php if($total_subcategories >0){?>fa fa-plus-circle<?php }?>” aria-hidden=”true”></i> <b><?php echo char_limiter($val[‘category_name’],20); ?></b></span>
<?php if($total_subcategories >0){
$cls=”;
$condtion_array_sub = array(
‘field’ =>”*,( SELECT COUNT(category_id) FROM wl_categories AS b
WHERE b.parent_id=a.category_id AND b.status=’1′) AS total_subcategories”,
‘condition’=>”AND parent_id = ‘”.$val[‘category_id’].”‘ AND status=’1’ “,
‘limit’=>20,
‘order’=>’sort_order’,
‘offset’=>0,
‘debug’=>FALSE
);
$result_sub = $this->category_model->getcategory($condtion_array_sub);
?>
<ul>
<?php foreach($result_sub as $val_sub){ ?>
<li><span><i class=”<?php if($val_sub[‘total_subcategories’] >0){?>fa fa-plus-circle<?php }?>”></i> <b><?php echo char_limiter($val_sub[‘category_name’],20); ?></b></span>
<?php if($val_sub[‘total_subcategories’]>0){
$cls=”;
$condtion_array_sub_sub = array(
‘field’ =>”*,( SELECT COUNT(category_id) FROM wl_categories AS b
WHERE b.parent_id=a.category_id AND b.status=’1′) AS total_subcategories”,
‘condition’=>”AND parent_id = ‘”.$val_sub[‘category_id’].”‘ AND status=’1’ “,
‘limit’=>20,
‘order’=>’sort_order’,
‘offset’=>0,
‘debug’=>FALSE
);
$result_sub_sub = $this->category_model->getcategory($condtion_array_sub_sub);
?>
<ul>
<?php foreach($result_sub_sub as $val_sub_sub){
if($total_subcategories>0){
$link_url = base_url().$val_sub_sub[‘friendly_url’];

}else {
$link_url = base_url().$val_sub_sub[‘friendly_url’];
}
?>
<li><a href=”<?php echo $link_url;?>”><?php echo char_limiter($val_sub_sub[‘category_name’],20); ?></a></li>
<?php }?>
</ul>
<?php }?>
</li>
<?php }?>
</ul>
<?php }?>
</li>

<?php }
echo “</ul>”;
} ?>