Sometimes appears situation when we need to display the block title(as link) even when this menu item don't have child items.
My suggestion is add to the configuration form new checkbox, and check it if we need display empty block(only title).
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | interdiff.txt | 847 bytes | eric115 |
| #13 | menu_block-empty_block-2327795-13.patch | 2.63 KB | eric115 |
| #9 | interdiff.txt | 1.2 KB | eric115 |
| #9 | menu_block-empty_block-2327795-9.patch | 2.34 KB | eric115 |
| #7 | menu_block-empty_block-2327795-7.patch | 2.5 KB | eric115 |
Comments
Comment #1
sanchiz commentedInitial patch.
Comment #2
sanchiz commentedComment #3
davidhernandezThis patch worked for me as designed.
Comment #4
davidhernandezI don't know if this is intentional or not, but it looks like when this is on, the menu block will still display, even on pages that are not in the menu.
Comment #5
dave reidI think it should only display if the current active trail is the same as the menu block selected menu.
Comment #6
euskarez commentedthis patch is not applied on version 7.x-2.x-dev of the module.
i need of this feature.
someone can help me?
Comment #7
eric115 commentedRerolled and updated patch to work with the changes to the way menu block works in the 7.x-2.x-dev version.
Comment #8
sam152 commentedCan we be consistent with the rest of the UI with full stops and case.
!empty() is the only condition requried here.
Maybe an empty div would be better here? It won't effect layouts in the same way a non breaking space will. Is there an even better way to render a block with no contents? I suspect not.
Standards. No capital, breaks 80 columns.
Comment #9
eric115 commentedHere is a new patch with Sam152's suggestions implemented.
Comment #10
eric115 commentedComment #12
sam152 commentedLooks pretty good for me. I'm guessing there wasn't an easy way to get the block to output with no markup whatsoever?
Comment #13
eric115 commentedThat is a good point, it looks like we can remove the "menu-block-wrapper" markup by not setting/nulling out the $data['content']['#theme'] variable.
This patch fixes that. Good catch!
Comment #14
sam152 commentedLooking good.
Comment #15
johnalbinReally? If the block title (as link) option is checked and there are no children, that means you are _on_ the page the block title would link to. [edit: oh! If the depth is limited, you might be on a page that is an descendant of the block title's page.]
Can someone update the issue description with a better explanation of why this is needed? I don't like to add new configuration for extreme edge cases; we have an API for that.
Comment #16
johnalbinGood news!
This is the default behavior in Drupal 8.[edit: whoops. I was wrong about this; there was a bug in the d8 version of menu_block.] It still doesn't make sense to me, but I trust it makes sense to some of you. [edit: I'll still trust you.] See #2757215: Add option to show block if menu tree contains no linksComment #17
johnalbinComment #19
johnalbinI stream-lined a little bit of the code, improved the UI, and committed it.
Comment #21
tarik.cipix commentedThis suddenly showed blocks that used to be hidden. Would be nice for a heads up in the release notes..