I'm trying to create custom block.tpl.php file for theming menus. I want to add a line of HTML code in div class="block-content".

I managed to do this for custom menu "Test" with template file "block--menu--menu-test-menu.tpl.php" in my custom theme folder where I suppose "--menu--" is name of the module and "menu-test-menu" is menu_name of menu as I see in Configuration manager. So, theming of custom menus is OK, tpl file with such file name is working.

But when I am trying to do the same for Primary navigation with template file "block--menu--main-menu.tpl.php" there is no effect on Primary navigation block code in web page.

Is there some difference between system Primary navigation menu block and custom menu blocks custom template names?

I found a workaround - I created a new custom menu called Main menu and use it instead of Primary navigation.
Custom template for this menu is named "block--menu--menu-main-menu.tpl.php" and it works.

But it should be possible to have custom block template for Primary navigation. May be I do not know right pattern for naming such template.

Thanks a lot!

And good luck for the Forum!

Most helpful answers

If you are struggling with finding the right template file names, you might consider enabling theme debug mode. This mode will print all available template file names in HTML comments in the source code of your page. (But do remember to disable this setting before launching your site, as it will affect performance.)

Hi @amilenkov, the main menu is provided by System module, so its:

block--system--main-menu.tpl.php

Comments

Hi @amilenkov, the main menu is provided by System module, so its:

block--system--main-menu.tpl.php
jenlampton's picture

If you are struggling with finding the right template file names, you might consider enabling theme debug mode. This mode will print all available template file names in HTML comments in the source code of your page. (But do remember to disable this setting before launching your site, as it will affect performance.)

Thanks for the advice. It works fine. I just had to find out how to activate the theme debug mode.

I tried adding (idea from D7 forums):

$conf [' theme_debug '] = TRUE;

in settings.php - but do not received anything in the code.

Then I used this idea:

https://github.com/backdrop/backdrop-issues/issues/1052#issuecomment-124...

and this set in the theme settings option to activate the theme debug mode.

Very convenient! I'm probably going to do this with all themes I'm developing or editing.

If there is a more correct way to activate the theme debug mode (without installing the Devel), please indicate this.

 

You can manually update the configuration by either editing the config file for system.core.json or export, then import, from the Configuration Management page (choose Configuration > System core settings).