Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I decide to theme menu blocks in my drupal 6.x.

I have copied block.tpl.php into my theme folder and I have renamed it to block-menu.tpl.php

but it seems it doesn't work !!

How can I modify the theme for menu blocks?

share|improve this question

2 Answers 2

You can user the theme developer module to check whether your template is called at all. It will show you what nameing conventions to use.

And just in case: You have to flush your caches to make sure new templates and theming methods are taken into account.

share|improve this answer
    
Thanks a lot. I will try this module but I searched about this issue and I found that block-menu.tpl.php doesn't work in drupal 6 –  Mehrdad201 Jul 1 '12 at 16:37

Actually, I think the problem is you re-named block.tpl.php block-menu.tpl.php instead of copying it as it works for me here. If it doesn't for you, or you want to theme a specific menu block, you can do something like this:

  1. Copy the default block.tpl.php to your theme's directory if it's not already there.

  2. Examine your html source and look for the ID of any block, eg <div id="block-menu-my-menu" ....> and then, id=

  3. Create a new block-menu-my-menu.tpl.php in your theme's directory, eg, block-BLOCK_ID.tpl.php.

You need to have BOTH otherwise Drupal 6 won't look for the specific block template override.

In either case, you have to clear the cache after creating both templates.

Now you should be able to theme this specific menu block.
For good measure, if you want to keep things clean, you can also create a directory structure for all of the templates, eg, create a tpl directory and then in there have subdirectories like block, node, page, etc, and put all your various templates in there.

ADDITION:

To be more precise, read: Drupal 6 Template Suggestions

What's a template suggestion? It's an alternate template (.tpl.php) file that you have created to override the base or original template file. Suggestions only work when they are placed in the same directory as the base templates. In other words, if you want comment-blog.tpl.php to display in your browser, comment.tpl.php also needs to exist inside your theme's folder and the two files must be in the same directory. comment.tpl.phpcomment.tpl.php

MORE ADDITIONS:

I am not sure what kind of development environment you have, but hopefully it is similar to MAMP, which I use for quick stuff on my MacBook:

  1. cd /applications/mamp/htdocs/modules/system
  2. cp block.tpl.php /applications/mamp/htdocs/sites/all/themes/YOURTHEME
  3. cd /applications/mamp/htdocs/sites/all/themes/YOURTHEME
  4. cp block.tpl.php block-menu.tpl.php

Now, if YOURTHEME already has a block.tpl.php, you can omit step 2, but just make sure that when all is said and done somewhere in or under the YOURTHERE directory, there is a directory that contains both block.tpl.php and block-menu.tpl.php. It could be in the base level directory, it could be in a subdirectory, regardless, just make sure both files are there. Also, make sure that YOURTHEME doesn't have a block.tpl.php elsewhere. If it does, make sure that block-menu.tpl.php is in that directory, eg, that you don't have two sets of block.tpl.php and block-menu.tpl.php files in different directories in YOURTHEME's directory structure for that would be confusing the theme registry build process and it would pick up only one of them.

Clear all caches to make sure the theme registry is rebuilt to see these new templates. If you have the Admin Menu module installed you can do this easily from the leftmost dropdown menu.

Now you can edit block-menu.tpl.php to theme all blocks created by the menu module.

share|improve this answer
    
Indeed, I want to theme ALL menu blocks. not specific menu block by ID. –  Mehrdad201 Jul 2 '12 at 14:28
    
so just make sure you COPY block.tpl.php to block-menu.tpl.php and flush caches to make sure it's noticed and you should be all set to go. –  Jimajamma Jul 2 '12 at 14:34
    
I had done this before. please read my first topic. block-menu.tpl.php doesn't work in drupal 6 –  Mehrdad201 Jul 2 '12 at 18:01
    
well, I don't know what to tell you then, because I am running drupal 6 and it works just fine here. –  Jimajamma Jul 2 '12 at 18:41
    
it is very confusing.. please tell me , have you written some codes in template.php file ??! –  Mehrdad201 Jul 3 '12 at 6:15

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.