Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I ran into a very legitimate reason to be able to disable MPC block & use another in it's place on certain pages, but the content persists anyway (even w/ the MPC block off).
* Technically* the block is obeying settings since the block region is gone, but the content that would be inside it is dumped on the page lower down without the block's html wrappers.
I can only imagine this topic has been touched on before (but I couldn't find a queue item) so I won't make this post longer than necessary.
Just for some point of reference, In Omega theme, Found the persisting content in:
<?php
function xxx_preprocess_page(&$vars) {
//This variable w/in preproc page had the persisting 'Main page content' block. \/
$vars['page']['content']['content']['content']['system_main']
}
?>
Comments
Comment #1
jwjoshuawalker CreditAttribution: jwjoshuawalker commentedI also tested with other themes before posting. It is repeatable with Bartik as well.
Comment #2
jwjoshuawalker CreditAttribution: jwjoshuawalker commentedTagging with usability since editing that block leads you to believe that you can hide it like any other, but it's content remains.
Google searching for things along the lines of 'hiding Main page content block' returns results of users being confused by the behavior, and then their instructions given are to either CSS display: none, write a module, or a template preprocess function. Not ideal.
My use case for example:
On the site, Main menu & it's 2nd level of links (9 links top level, and 5-6 each sub level) are all taxonomy terms and built w/ Taxonomy Menu. So each of these 45 pages are just pathed to the term page. This is the intention for all but 3 of the pages, so everything to this point feels like it was done very clean & efficiently. These other 3 pages need to show something else, so seeing that Drupal's main content section is now placed in a block w/ D7, my first thought was "Ok, I can just hide that one on these 3 pages, and replace w/ a different block for what is needed on these pages". The outcome is very different though, and confusing if you aren't a developer.
Another note: I've only tested w/ node & taxonomy term pages.
Comment #3
BarisW CreditAttribution: BarisW commentedHow can we reproduce this?
Comment #4
jwjoshuawalker CreditAttribution: jwjoshuawalker commented@BarisW
The fastest way is going to seem silly. Create a node & turn off "Main page content" block for it's path.
On a brand new site, Standard install profile, the HTML for the area goes from being:
To just:
The rest of the node's markup stays the same afterwards.
Comment #5
jwjoshuawalker CreditAttribution: jwjoshuawalker commentedDoes this make sense?
Comment #6
dalehgeist CreditAttribution: dalehgeist commentedYes, it makes sense. I am using generic nodes to set up my nav, but I am populating those nodes exclusively with blocks (views, etc.) - I don't want any content to show. Yes, I can simply not enter any content, but that feels like a workaround. I feel like my approach is Drupalesque, yet the Drupal core UI (in this case, block visibility settings) is not yielding the expected result.
Comment #6.0
dalehgeist CreditAttribution: dalehgeist commentedReaffirm that block is obeying but content persists
Comment #7
swentel CreditAttribution: swentel commentedFor more discussion on this topic, see #687686: Prevent hiding the Content Block on particular pages