I want to make breadcrumbs dynamically from web service data. I want to show the hierarchy like this: Beranda / Kugi / Category / Sub-category
where the Category
is the parent of Sub-category
The problem is I get the value of Sub-category
from $this->input->GET('KodeSubKategori')
from my tree view. But, I cannot get the value of Category
.
Here is my controller:
//to get the value of Sub-category
$paramSubKategori = $this->input->GET('KodeSubKategori');
$get_url_subkategori = $this->ws_url->GetUrl('SubKategoriRetrieve?KodeSubKategori='.$paramSubKategori);
$get_json_subkategori = json_decode(file_get_contents($get_url_subkategori), true);
I want to get the data Category
although I don't click it in tree view
So how can I fix this? Thanks.
I think the problem is with GET
$this->input->GET('')
It is use as
$this->input->get('');
Read Reference
Add this code on your controller method
$data['crumb']=array(
array('label'=>'Beranda','link'=>'your dynamic link'),
array('label'=>'Kugi','link'=>'your dynamic link'),
array('label'=>'Category','link'=>'your dynamic link'),
array('label'=>'Sub-category','link'=>'') # Last link should be blank for active link
);
$this->load->view('yourfilename',$data); # yourfilename - name of your view file
On view yourfilename.php page add this-
<ul>
<?php $tb=count($crumb); for($c=0;$c<count($crumb);$c++){ if(($tb-$c)>1){?>
<li><a href="<?php echo $crumb[$c]['link']?>"> <?php echo ucfirst($crumb[$c]['label']);?></a> /</li>
<?php }else{ ?>
<li class="active"><?php echo ucfirst($crumb[$c]['label']);?></li>
<?php } }?>
</ul>