I am building Bootstrap-based theme and I have created one block that renders the main menu.
return array(
'#markup' => drupal_render($menu),
'#theme' => "menu__mobile",
);
As seen above I state that the theme file should be menu--mobile.html.twig
. If I state no "#theme" variable it uses the default menu--main.html.twig
.
The problem is that if I use my own twig-template nothing comes out! The .twig
-files are identical inside (although I will modify the mobile file) and are based on the Bootstrap theme (http://drupal-bootstrap.org/api/bootstrap/templates!menu!menu--main.html...). If I use the default menu--main.html.twig
it renders the menu.
menu--mobile.html.twig
is loaded as if I put some <h1>foo</h1>
into the file it is shown, but it seems that items
variable is empty.
Any ideas how to solve or debug this problem?
Comments
#markup is a string, you
#markup is a string, you rendered the menu early.
Pimp your Drupal 8 Toolbar - make it badass.
Adaptivetheme - theming system for people who don't code.
So how should I proceed? Why
So how should I proceed? Why does this work as wanted with original template file, but not with another? I do not understand :)
I have no idea what you are
I have no idea what you are talking about.
Pimp your Drupal 8 Toolbar - make it badass.
Adaptivetheme - theming system for people who don't code.
I mean that this #markup
I mean that this #markup works if I do not set any #theme.
Now I understood that the render part should be omitted, but haven't yet find out a way to make it work.
I use https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Menu!menu.api.php... to build the menu, but not yet quite sure what should be returned so that the template makes the rendering.
return array( '#theme'
This solved the problem and now the menu renders.
\,,/
Well done ;)
Pimp your Drupal 8 Toolbar - make it badass.
Adaptivetheme - theming system for people who don't code.
Theme
I already follow these steps, I've done this before with other templates and works fine. I don't know what's wrong.
About your recommendation, I'll look for that and try it later, but for now I need to find out what I did wrong or what's different with this template.Another question I'm having trouble with, on another page I'm using the template Simplicity, which has some icons at the home page, I have some icons of my own and I'm trying to replace them with no success. Could you help me with this too?