hook_theme_suggestions_HOOK_alter() Call to undefined method id()

Created on 4 April 2024, 8 months ago
Updated 30 April 2024, 7 months ago

The $variables array element "content" doesn't contain anymore the old data structure (see screenshot in attachment).

This means that the following script doesn't work anymore:

/**
* Implements hook_theme_suggestions_HOOK_alter().
*/
function MY_MODULE_theme_suggestions_printable_alter(array &$suggestions, array $variables) {
$suggestions[] = 'printable__' . $variables['content']['#node']->type->entity->id();
}

and templates are not overridden anymore.

🐛 Bug report
Status

Fixed

Version

3.1

Component

Code

Created by

🇧🇪Belgium fab01

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

Comments & Activities

  • Issue created by @fab01
  • 🇧🇪Belgium fab01

    I have fixed the issue myself.

    Thanks for the (??) help.

    Really appreciated.

  • Status changed to Fixed 8 months ago
  • 🇦🇺Australia nigelcunningham Geelong

    Sorry for the slow response fab001, but you do seem to be assuming that we're paid to maintain this code. That's not the case for me at the moment, so I'm putting my effort into seeking a job and seeking to make a job for myself.

    Perhaps you could post the change you made, so that others in the same situation will find your issue useful?

    Regards,

    Nigel

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024