Skip to content

Unshift crash breadcrumb #7

@tjapro

Description

@tjapro

When unshift a breadcrumb, the final result doesn't work fine.
Possible resolution:

// construct output
            /*
            foreach ($this->breadcrumbs as $key => $crumb) {
                $keys = array_keys($this->breadcrumbs);
                if (end($keys) == $key) {
                    $output .= $this->crumb_last_open . '' . $crumb['page'] . '' . $this->crumb_close;
                } else {
                    $output .= $this->crumb_open.'<a href="' . $crumb['href'] . '">' . $crumb['page'] . '</a> '.$this->crumb_divider.$this->crumb_close;
                }
            }*/
// newer construct output
            $num = count($this->breadcrumbs);
            $i = 0;
            foreach ($this->breadcrumbs as $key => $crumb) {
                if (++$i === $num) {
                    $output .= $this->crumb_last_open . '' . $crumb['page'] . '' . $this->crumb_close;
                } else {
                    $output .= $this->crumb_open.'<a href="' . $crumb['href'] . '">' . $crumb['page'] . '</a> '.$this->crumb_divider.$this->crumb_close;
                }
            }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions