Breadcrumbs not rendering properly

I am having a lot of trouble getting breadcrumbs to render correctly. For example, in a view I am setting it up like this:




$this->breadcrumbs=array(

	'Patients'=>array('patient/admin'),

	$model->patient_id=>array('patient/view','id'=>$model->patient_id),

        'Enrollment'=>array('view','id'=>$model->id),

        $model->id=>array('view','id'=>$model->id),

        'Lesion Grid',

);



I’d expect to see

Home » Patients » 1 » Enrollment » 1 » Lesion Grid

with the correct links - what I do see though is this

Home » Patients » 1 » Enrollment » Lesion Grid

and the links are incorrect. the “1” links to the enrollment view id (1) and the patient value doesn’t show up at all. This seems to happen when the patient id and the enrollment id are equal. If the patient id and the enrollment id are not equal, then it renders correctly.

Home » Patients » 1 » Enrollment » 11 » Lesion Grid

with the correct linking. I’m seeing similar strange breadcrumb issues throughout my project. Any ideas?

I can confirm this… I think it’s putting all the labels as key in an array, and duplicate keys are not allowed… I’m not sure if this is intentional or not, since each label in a breadcrumb should be a unique identifier of a URI.

You could make them unique by using a word like ‘patient 1’ instead of just ‘1’, that would make it easier to identify a page and easier to click

Ah, ok I see what you are saying. I guess I will try something like that to work around the issue - but it DOES seem like a valid issue, to me. A bug.

I noticed that behavior too, but I never had the problem like you because I use only text labels :)

The solution could be to allow the CMenu-like syntax:




$this->breadcrumbs=array(

    array('label'=>'Patients', 'url'=>array('patient/admin')),

    // ...

);