- Issue created by @Liam Morland
- 🇫🇷France just_like_good_vibes PARIS
Hello, would you share with us your SDC component definition and how you use it please ?
- 🇨🇦Canada Liam Morland Ontario, CA 🇨🇦
Here is the component. I noticed this problem with the
menu
property.I was able to make it work by adding the
|string
cast in this line. - 🇫🇷France just_like_good_vibes PARIS
thank you.
may i have a copy of the exception you had please? - 🇨🇦Canada Liam Morland Ontario, CA 🇨🇦
This is the error:
TypeError: Drupal\simplify_menu\MenuItems::getMenuTree(): Argument #1 ($menuId) must be of type string, Drupal\Core\Render\Markup given, called in .../modules/contrib/simplify_menu/src/TwigExtension/MenuItemsTwigExtension.php on line 42 in Drupal\simplify_menu\MenuItems->getMenuTree() (line 115 of .../modules/contrib/simplify_menu/src/MenuItems.php).
The reason is this in the following line from gcds-top-nav.twig,
menu
isDrupal\Core\Render\Markup
instead of a string.{% set items = simplify_menu(menu) %}
- 🇫🇷France just_like_good_vibes PARIS
Thank you, now i see it clearly.
I will post an improvement to cope with it.by the way, do you know the module sdc_devel?
that's not quite a good practise to use backend stuff from your twig sdc files, they are supposed to be quite "UI only".
but we could discuss that on the slack of ui patterns2 if you like. - 🇨🇦Canada Liam Morland Ontario, CA 🇨🇦
I didn't know about
sdc_devel
. I will check it out.Are you saying that it is not a good idea to call
simplify_menu()
in a SDC Twig file? Since SDC do not have preprocess, I don't see any obvious way of removing it.