Open klonos opened 7 years ago
A user can use a title-less block with an H2 content.
For that use case, wouldn't it make more sense and be more semantically correct to allow regions to have a title? The HTML would be an H# tag for the region's div, not the block's div. The block's div is the region's child, and would not, semantically, apply to the whole region.
Region Titles would be a good contrib module.
A user can use a title-less block with an H2 content.
Yes, but that implies needing to first edit the HTML text filter to allow H2 tags, or switching to code (full HTML) format and adding those tags "manually". Not as user-friendly as clicking your way in the same manner as you can add block titles. That + what @jlfranklin said about "semanticallity" <-- claiming ™️ on that word 😄
I'm sorry, I think I read the title of this issue as something about adding a block with a title to a region instead of a title to the region itself. @klonos, you and I are in agreement on this.
@jlfranklin 😄 that was #2640. Its previous title was "Custom blocks are not being rendered if they have only title and no content.". Now it was re-titled and re-purposed to simply clarify things in the UI so that novice users have better understanding of how things work (and hopefully why), without having many WTFs. I have come around to realize that what I was trying to achieve was (ab)using a block in order to add a title to a region.
This issue here is in order to have it so that people can achieve that task in a more "proper" way, which will at the same time be as easy as adding a block title through the manage blocks UI plus will be resulting in things being rendered semantically correct.
OK, PR up for review that adds a "Region title" checkbox in the region config dialog:
...which when checked allows to set title, heading/tag, and classes:
Please do not mind the 1000s of test failures for now 😅
...I plan to make the logic a bit more elaborate/smart in order to have all blocks within a region be semantically correct if set to use headings. So for example, if the region title is set to a h2, then the titles of all blocks within that region will automatically get a h3 (unless of course their style setting is set to "dynamic"); if the region is a h3, then blocks within will get a h4, etc. But this might be a follow-up.
I don't think this is an 80% use case. I'm in agreement with @jlfranklin that this should be a contrib module. It would be straightforward to form_alter the region form and add these settings there.
Removing core milestone, adding tag for "contrib candidate".
@klonos can you elaborate more on your use-case? In my 22 years of building websites I've never needed a label for a region. Can you give me a real world example? Do you have a screenshot or can you describe what goes in a region that needs a title?
I'm going to vote for contrib.
Example use case: A user wants to add a title to a sidebar region, but this cannot be achieved by using title-only (content-less) custom blocks. See #2640
PR by @klonos: https://github.com/backdrop/backdrop/pull/2358