Overriding output using preprocess theme functions

Created on 9 September 2020, almost 4 years ago
Updated 28 July 2023, 11 months ago

Problem/Motivation

I am trying to change the html output of the dropdown sub menu, and in particular the output of the link itself. I would like to output the link "description" text BEFORE the menu item. Using the nterface you can output it after the text and within the tag but it doesnt seem possible to change that.

There are other issues where people seem to have done similar things by overriding the preprocess theme functions, but I have not been able to get this to work.

So please can someone confirm how you do this or if it is not possible.

Steps to reproduce

I have tried inserting the entire theme function template_preprocess_superfish_menu_items from superfish.theme.inc into my theme file, and although the menu does display it stops rendering properly, only the top level shows and no children are being added.

I have also tried adjusting the function to see if it works to simply insert a variable for description without the rest of the function but that does not work, resulting in errors such as "Error: Cannot use object of type Drupal\\Core\\Menu\\MenuLinkTreeElement as array" and "Error: Call to a member function getDescription() on null" depending on how I have tried to adjust the function.

Proposed resolution

Ideally if it is possible to override these functions some documentation or examples of working theme functions would really help.

I have tried using the issue below as an example but I am not trying to use menu extra items but just to be able to add the description as a variable that can then be used in the template.

✨ Feature request
Status

Active

Version

1.4

Component

Documentation

Created by

πŸ‡¬πŸ‡§United Kingdom gsquirrel London

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.

Production build 0.69.0 2024