• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Solved] Custom Bread Crumbs Foreach Loop Codeigniter

#1
I have a problem with my breadcrumbs currently when I am in my help folder the url out puts.


Code:
http://localhost/project/admin/common/test?directory=help/sub


It should read


Code:
http://localhost/project/admin/common/test?directory=help



Code:
<ul class="breadcrumb">
    <li><a href="http://localhost/project/admin/common/test">Catalog</a></li>
    <li><a href="http://localhost/project/admin/common/test?directory=help/sub">Help</a></li>
    <li><a href="http://localhost/project/admin/common/test?directory=help/sub">Sub</a></li>
</ul>

How can I make sure it set the previous directory url correct

On my controller code I set the breadcrumbs like so


PHP Code:
$data['breadcrumbs'] = array();

$data['breadcrumbs'][] = array(
'text' => 'Catalog',
'href' => base_url('admin/common/test')
);

$directory_names explode('/'$this->input->get('directory'));

foreach (
$directory_names as $directory_name) {
$data['breadcrumbs'][] = array(
'text' => $directory_name,
'href' => base_url('admin/common/test?directory=' $this->input->get('directory'))
);



Attached Files
.php   Test.php (Size: 4.7 KB / Downloads: 101)
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply

#2
Hi,

Here is an idea:

PHP Code:
$directory_names explode('/'$this->input->get('directory'));
$directory_done '';
foreach (
$directory_names as $directory_name) {
 
       $directory_done .= ($directory_done <> '''/':'').$directory_name
    
$data['breadcrumbs'][] = array(
        
'text' => $directory_name,
        
'href' => base_url('admin/common/test?directory=' $directory_done)
    );

A good decision is based on knowledge and not on numbers. - Plato

Reply

#3
(08-09-2017, 02:56 AM)salain Wrote: Hi,

Here is an idea:

PHP Code:
$directory_names explode('/'$this->input->get('directory'));
$directory_done '';
foreach (
$directory_names as $directory_name) {
 
       $directory_done .= ($directory_done <> '''/':'').$directory_name
    
$data['breadcrumbs'][] = array(
        
'text' => $directory_name,
        
'href' => base_url('admin/common/test?directory=' $directory_done)
    );


+1 That has worked perfect Thank you
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.