Frage

I need your help for a problem that seems childish but that I can't solve.

I would like to activate a block (that is already activated for other content-types pages and works just fine) to show it up on a new content-type. I just checked the box in admin->structure->block->configure->visibility parameters for that specific content-type just like I did for others. However, it doesn't show up.

Here is a screenshot of block parameters config (you never know ^^).

This block is located in sidebar_second region. So I checked with dpm() if this region was set in both content-types.

Here I can see that is actually set for my content-type basic page where the block shows up well.

But here I see that my region doesn't exist at all and thereby my block doesn't appear.

I created a new test block and located it in sidebar_second region as well to determine if the problem is the specific block itself or the content-type page... Apparently, I guess it is the second solution because it doesn't show up neither.

Also, I tried to locate my blocks into the sidebar_first region (that already exists for my content-type testimonial). Unfortunately, it doesn't work neither. Of course, it works well on content-type basic page...

To make sure the page code is not overriden in my testimonial.module or template, I checked twice the hooks I implemented and all my templates files... I found nothing that could cause that problem.

Eventually, I googled my problem and found that bug report (closed because cannot be reproduced): https://drupal.org/node/1777072 but I think that it would be very unlucky as it happens...

To choose, it surely is a mistake that I don't see rather than an uber rare bug that happened to 10 people in the world xD

That's why I need your help, ô stackoverflow people!

War es hilfreich?

Lösung 2

I just wanted you to know that I figure it out.

Indeed, my function hook_node_view() implemented menu_set_active_item("testimonial") to solve a navigation detail (to force highlighting a menu item...). However, it modified the q variable in URL and Drupal didn't know anymore that the page was actually a node type testimonial (and thought it was actually a View).

Thereby, my block couldn't appear because it was supposed to show up on node type testimonial (and not on a View).

So, I had to save the true nature of my page in a variable using menu_get_active_trail() before implementing menu_set_active_item().

Eventually, I had to pass this variable in my hook_block_view() to display the block.

I am sorry for not having given you all the information that was necessary to answer my question. I thought the custom code wasn't very suspect but I was wrong. I'm still a junior Drupal developer and I didn't know what menu_set_active_item() method did exactly. Thanks however and have a great weekend!

Andere Tipps

My first though it that the testimonial content type could be using a different page template to the basic page content type.

You will need the line:

<?php echo render($page['sidebar_first']); ?>

In the page template used by testimonial.

Hmm, actually I'm not at all convinced that this is the correct solution but I'll post just in case it helps...

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top