HTML break tag in menu link

Created on 7 October 2019, over 5 years ago
Updated 28 July 2023, almost 2 years ago

Is there a way to use the <br> tag in a menu title? Currently it just prints out the <br> tag.

Thank you.

Feature request
Status

Active

Version

1.0

Component

User interface

Created by

🇨🇦Canada avo webworks Ottawa, Ontario, Canada

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇧🇪Belgium hansrossel

    In a custom module:

    function MODULENAME_preprocess_superfish_menu_items(array &$variables) {

    .... copy everything the first part of the function from superfish.theme.inc ....

    $attributes = $item_attributes->__toString();
    $menu_item_title = (string) $item['text'];
    $menu_item_url = $item['url']->toString();
    $link_element = '' . $menu_item_title . '';;
    $link_element_menuparent = '' . $menu_item_title . '';;

    $variables['menu_items'][] = [

    .... copy the last part of the function from superfish.theme.inc ....
    }

    Copy superfish-menu-items.html.twig to your theme and add raw to the output of the menu links

    {% if item.children is not empty %}
    {{ item.link_menuparent|raw }}
    {% else %}
    {{ item.link|raw }}
    {% endif %}

  • Status changed to Closed: won't fix 17 days ago
  • 🇧🇪Belgium lobsterr

    I don't think we will implement this.
    1) It is a security problem
    2) A default menu system doesn't support it either

    Please you work around solutions

  • 🇨🇦Canada awasson

    @lobsterr, fair enough and thanks for closing the issue so that it's not just hanging.

    The method I proposed using BBE like markup ( #4 HTML break tag in menu link Active ) has been useful in websites I've built for universities and associations where menu links need this type of treatment for visual context. Rather than try to mess with Superfish core, I added a custom module to override Superfish to use my tokens when rendering the menu. If I have the bandwidth, I'll release a module or I'll add to the docs so that others can work around it.

    Cheers,
    Andrew

Production build 0.71.5 2024