The theme_toolbar_toggle() function in core simply outputs a link, generated by the l() function. This link alone does not need to be run through the theme layer.

function theme_toolbar_toggle($variables) {
  if ($variables['collapsed']) {
    $toggle_text = t('Show shortcuts');
  }
  else {
    $toggle_text = t('Hide shortcuts');
    $variables['attributes']['class'][] = 'toggle-active';
  }
  return l($toggle_text, 'toolbar/toggle', array('query' => drupal_get_destination(), 'attributes' => array('title' => $toggle_text) + $variables['attributes']));
}

Let's move this link into the toolbar.html.twig file, and allow theme devs to change it there, if needed.

<nav id="toolbar" role="navigation" class="{{ attributes.class }} clearfix"{{ attributes }}>
  <div class="toolbar-menu clearfix">
    {{ toolbar.toolbar_home }}
    {{ toolbar.toolbar_user }}
    {{ toolbar.toolbar_menu }}
    {% if toolbar.toolbar_drawer %}
      {% if toolbar.collapsed %}
        <a href="{{ url('toolbar/toggle', toolbar.options) }}"{{ toolbar.attributes }}>{{ 'Show shortcuts'|t }}</a>
      {% elseif %}
        <a href="{{ url('toolbar/toggle', toolbar.options) }}" class="toggle-active {{ toolbar.attributes.class }}"{{ toolbar.attribtues }}>{{ 'Hide shortcuts'|t }}</a>
      {% endif %}
    {% endif %}
  </div>
  {{ toolbar.toolbar_drawer }}
</nav>

Comments

jenlampton’s picture

Issue summary: View changes

add twig example

jessebeach’s picture

Hi all, I just wanted to mention that the toolbar theme issues are being addressed in the responsive toolbar patch. I just switched from tpl to twig in the latest patch.

#1137920-282: Fix toolbar on small screen sizes and redesign toolbar for desktop

I would suggest closing this issue as a duplicate or at least postponing it. I'd like to avoid you all spending time on unnecessary work here.

thedavidmeister’s picture

Status: Active » Closed (duplicate)

the function theme_toolbar_toggle() does not exist in latest 8.x HEAD. This issue must be a duplicate, probably with the one referenced in #1.

thedavidmeister’s picture

Issue summary: View changes

remove does