The issue is that I have a Menu Block with parent items that don't yet have child menu items, but eventually might. I want to display another block in place of the menu block if the menu block is not on a particular page. I have tried rules, rules bonus blocks, context, even conditions in my page templates but I am a PHP novice and so far it doesn't seem possible to create a condition based on a block's visibility. I hope that makes sense! Any help much appreciated! I am using D7.
I was able to do this with panels, view blocks and a custom PHP visibility condition. I think Panels is trivia. You could do this with Drupal's built-in block administration.
I had a news block that would show up on the city page. It would display all the news of the city. If there was no news for that city, it would display [another] news block for that state. If there was no news for that state, it would display [another] news block for the country.
Each of these block was a view. In the PHP visibilty I would check for views results using the views_get_view_result($name, $dispay_id = NULL [, $args])
So the county block would check if the state and city block view returned any results, if FALSE (no results) then it would get displayed. State would check if city block view return any results, if FALSE (no results) then it would get display.
If you blocks are not views, then I don't know how to solve the problem easily (unless the last block is the only one that is not).
One of my blocks was not a view but a custom block generated via module, so create a view which would generate the similar content, at least could list the items or give the total count of items. Then I checked if there is any result returned by
views_get_view_result($name, $dispay_id = NULL [, $args]), if yes then don't show this block else show the block.. and it worked for me. Hope this helps someone in need.
I had very similar problem with Menu Block module so I wrote simple Context module/plugin Context Active Menu Depth that sets appropriate context when specified condition (menu depth, menu name and has_children) are met. Code is still experimental but you'll get the idea. In my case I needed to display replacement block if Menu Block with 2nd level of links is not present.