How to override breadcrumbs ?

How to override breadcrumbs ?

by Javier Cuadrado -
Number of replies: 2

Hi,

I am trying to modify the default breadcrumbs of Moodle.

Specifically, I would like to remove all the elements that are not clickable. For example these ones.

I've found this function in outputrenderers.php but I don't know if it's related with this.

Could you help me with that ?

Thanks!

 
protected function render_breadcrumb_navigation_node(breadcrumb_navigation_node $item)  {

        if ($item->action instanceof moodle_url) {
            $content = $item->get_content();
            $title = $item->get_title();
            $attributes = array();
            $attributes['itemprop'] = 'url';
            if ($title !== '') {
                $attributes['title'] = $title;
            }
            if ($item->hidden) {
                $attributes['class'] = 'dimmed_text';
            }
            if ($item->is_last()) {
                $attributes['aria-current'] = 'page';
            }
            $content = html_writer::tag('span', $content, array('itemprop' => 'title'));
            $content = html_writer::link($item->action, $content, $attributes);

            $attributes = array();
            $attributes['itemscope'] = '';
            $attributes['itemtype'] = 'http://data-vocabulary.org/Breadcrumb';
            $content = html_writer::tag('span', $content, $attributes);

        } else {
            $content = $this->render_navigation_node($item);
        }
        return $content;
    }


Breadcrumbs

Average of ratings: -
In reply to Javier Cuadrado

Re: How to override breadcrumbs ?

by Dominique Palumbo -
Picture of Particularly helpful Moodlers Picture of Plugin developers
Hi,

You can do it by adding two lines of js in the administration > presentation > additional HTML
$('.breadcrumb-item').hide();
$('.breadcrumb-item:has(a)').show();

Witout touching theme or core.

And the answer to the question you don't ask : I do not recommand it. : )

Have a good day.

Dominique.