Problem/Motivation
https://www.drupal.org/project/block_content_template something like this
Steps to reproduce
NA
Proposed resolution
Add a new setting (similar to media) for allowing standalone URLs.
When enableda view tab to the block content entity will appear.
Add default template when using the view route of the block only As a preview of what the block will look like if that helps
Remaining tasks
Review if it's worth it
Implement
Write test
code review
User interface changes
New tab to "View" block without being placed on a page
New view tab

View page

API changes
Block content now has a settings form with one setting for enabling standalone URLs.
Data model changes
NA
Release notes snippet
TBD
Comments
Comment #3
smustgrave commentedComment #5
smustgrave commentedComment #6
smustgrave commentedSo my current questions are
1. Is this the correct way?
2. Should we use that .bc route?
3. Do we need a "view block content" permission? Was having a hard time thinking the use case.
4. Is it okay I updated the previous .bc routes.
5. 0 idea why BlockContentTranslationUITest::testTranslationUI failed.
Comment #7
smustgrave commentedComment #8
larowlanLeft some more feedback on the MR
Comment #9
larowlanComment #10
andyf commentedThanks for the work on this... I could be misrepresenting, but I believe there were concerns raised with taking this approach in #2704331: Ability to display block_content entities independently, also outside of Blocks however (eg. #2704331-19: Ability to display block_content entities independently, also outside of Blocks). Do we have a response to that at all?
Comment #11
smustgrave commentedThis template is only going to be picked up when using the view route of the block. As a preview of what the block will look like if that helps
Comment #12
smustgrave commentedAddressed the feedback. Ready for another review
Comment #13
andyf commentedThanks for humoring me @smustgrave, that wasn't clear to me when looking at the IS and description of the linked module.
Comment #14
larowlanJust one minor thing and one question, left in the MR
Comment #15
smustgrave commentedAddressed feedback
Comment #16
wim leersComment #17
smustgrave commentedSeems removing that render key caused some failures. Need to investigate why.
Comment #18
smustgrave commentedLets see if that works.
Comment #19
smustgrave commentedFixed!
@Wim Leers I added some screenshots those work?
Comment #20
wim leersAh … so it's not just a Twig template, it's also new routes and tabs! That wasn't clear at all to me based on the title + summary 😅
Seems like #13 also contains pretty critical information that belongs in the issue summary. And perhaps also on the docblock in the Twig template itself? 🤔
Comment #21
smustgrave commentedUpdated will update the template too!
Comment #22
smustgrave commentedLeft a small in the template.
Comment #23
larowlanLeft a comment on the MR
Comment #24
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #25
smustgrave commentedRebased
Comment #26
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
This does not mean that the patch needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #27
smustgrave commentedComment #28
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
This does not mean that the patch needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #29
smustgrave commentedComment #30
larowlanStill keen to understand why we need to manually add the list cache tag
Comment #31
smustgrave commentedOdd so removing that line worked now. No clue but I'll take it.
Comment #32
larowlanThis looks good to me, thanks @smustgrave
Comment #33
lauriiiWhat's the use case for the block content view tab? I understand editors may want to use it to preview the block but I'm not sure if the view tab is ideal for that.
Reading the description of the module, I wonder if #3371753: Fall back to 'edit-form' as default $rel in EntityBase::toUrl() has helped solve part of the problem?
If we decide to do this, I think we may need to implement something similar to what we did in Media where this would not be enabled by default. It seems strange that anonymous users who may have access to view blocks, would be able to visit these URLs. See #3017935: Media items should not be available at /media/{id} to users with 'view media' permission by default for the media issue.
Comment #34
smustgrave commentedThink you answered it. This is to provide editors the ability to preview blocks without having to place on a page first.
Since block content doesn’t have a settings from guess one will have to be added.
Comment #35
smustgrave commentedUpdated issue summary to include the settingsForm being added.
Started a CR as well
Wasn't sure how we wanted to handle admin/content/block/{block-content} when the standalone_url setting is off. Can't deprecate the route as it is used.
Think it's ready for some review.
Comment #36
larowlanLeft a review
Comment #37
rkollerI've taken a look yesterday night, in general i like the feature and it is also consistent wording wise with the approach taken for the media module. there is only one minor detail I am unsure about is into which group the "block content settings" link is placed on
/admin/config. It not really feels like the perfect fit to put it under "user interface". My first goto in the list of available groups would have been content authoring probably. but that is only due to the fact that the term is closest to the general term "content", defining stand alone urls for content blocks isnt exactly "content authoring" either. while the term "user interface" is simply too generic (i wouldn't even considered or expected a setting like that there). for media settings it is easier since there is a dedicated group media available. tricky. "user interface" just seems not the exact right fit imho.Comment #38
smustgrave commentedAddressed most of the feedback but leaving NW for the open threads.
@rkoller I didn't know either where it should go but speaking to @larowlan we picked that one as there didn't seem to be a better spot.
Comment #39
rkolleri completely agree. and i've only looked at it from the perspective where to sort the link in the list of available groups. Another option might be to introduce a new one. Yet another option might be to go with the user interface group where the patch currently puts it and wait what comes out of the restructuring the admin ui menu structure and tackle the question/problem in the context of that effort (might be the pragmatic approach).
or in addition i could bring up the topic either informally in the ux channel or raise it during the next ux meeting. just to get a few more perspectives (but i doubt anyone might have a better idea for the destination with the list of current groups).
Comment #40
smustgrave commentedWell if we add a new Block Content or Block section, similar to Media. Would it be odd if it's the only setting?
May make sense for contrib just can't think of anything on the horizon for core to add another link to that section.
Comment #41
rkollerwell without the patch applied user interface also has just a single link (Shortcuts) in it.
but just adding a new group should also handled with care imho. would it make sense to add it, i mean are there many different contrib modules related to blocks that would justify that?
Comment #42
smustgrave commentedCreate a new section for "Block" @larowlan some of the stuff requested we remove would break existing behavior.
Comment #43
smustgrave commentedFeedback addressed
Comment #44
acbramley commentedNeeds a reroll
Comment #45
smustgrave commentedWill address it tomorrow!
Comment #46
smustgrave commentedResolved all feedback. Still passing.
Comment #47
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #48
smustgrave commentedRebased
Comment #49
smustgrave commentedAddressed feedback.
Comment #50
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #51
smustgrave commentedRebased
Comment #52
larowlanFrom #39 and #41 it feels like @rkoller isn't sure that a new group is the right approach. I think we should get the UX team to make a suggestion either way. We could bundle in the wording on the form as part of that - I realise this is similar to the Media settings form but in this instance its only for preview so the wording/use case is slightly different. Tagging for UX team (I think that's the correct tag)
Leaving at needs review
Comment #53
rkolleri have had added this issue to the shortlist for todays usability meeting, but yesterday a request for the review of the navigation module came in. since they try to get it into core as experimental we've discussed the navigation module today. we hopefully find time next week or i might pick the brains of the other regulars during the week.
my main concern about the new group here was twofold. for one the new group
Blockis created with only a single pageBlock Content Settingsin it and that single page has only a single interface component, a checkboxStandalone Block Content URLon it. on the other hand i think we should be mindful about the number of categories/groups available as well as what types there are. the majority is currently organized by topic/general function, not many are based on an actual entity type/module? media for one but that contains not only pages for the media module but also anything related to images and files.Comment #54
rkollerUsability review
We discussed this issue at #3438916: Drupal Usability Meeting 2024-04-12. The recording of the meeting can be found at: https://www.youtube.com/watch?v=1uFZZtA_xDw
For the record, the attendees at the usability meeting were @AaronMcHale, @BlackBamboo, @benjifisher, @rkoller, @simohell, @skaught, and @worldlinemine.
If you want more feedback from the usability team, a good way to reach out is in the #ux channel in Slack.
At first sorry for the delay, but getting our train of thought and the reasoning behind our recommendations into a (hopefully) coherent comprehensible shape, instead of providing just a incoherent list of bullet points with our recommendations, I was sort of struggling over the course of the last few days. :/
As one of the first steps in the meeting, we've compared the behavior of a block page with and without the MR applied:
MR not applied
Block descriptionlink:/admin/content/block/1OperationsEdit button:/admin/content/block/1MR applied - "Standalone Block Content URL" and "Standalone media URL" ticked
Block descriptionlink:/admin/content/block/1(uses Olivero)OperationsEdit button:/admin/content/block/1/edit(uses Claro)Accessing
/admin/content/block/1as an anonymous user in a private browser window leads to anAccess deniedpage in Olivero.Media namelink:/media/1(uses Olivero)OperationsEdit button:/media/1/edit(uses Claro)Accessing
/media/1as an anonymous user in a private browser window displays the page for the first media item in Olivero.MR applied - "Standalone Block Content URL" and "Standalone media URL" unticked
/admin/content/block/1redirects to/admin/content/block/1/edit/media/1redirects to aPage not foundpageOne detail that sparked our attention, on one hand you have a consistent patterns used for paths and the themes used for displaying the content in the different contexts with the standalone URLs for blocks and media ticked, on the other hand you have the discrepancy when standalone URLs are both unticked for blocks and media, how none available paths are then handled for each entity type.
From there the discussion shifted into a brief outline of the historical evolution of content entity types. Initially only nodes were field-able, then terms became field-able, in Drupal 8.0 blocks got field-able, and then finally media items. Over time by general demand the different content entity types evolved more and more, added new features and moved towards a feature parity and a sort of uniform set of UI components for the user.
But we have to be clear what the use case for an entity type is and it is important that we don't deviate from it or be ambiguous about it, otherwise things become confusing in particular for people who are learning Drupal for instance. If you create for example a block called
imageand you put an image field on it, what is the difference to a media item other than its location in the media library from the end users perspective? Same if you have block with four fields and a node with the same set of fields, the difference due to the strive for consistency in UI components and their micro copy is marginal, making it challenging to distinguish and pick one of the two.In consequence the group came to the insight and conclusion, certain things should be consistent across content entity types, but there should also be fundamental differences between the various entity types. We should be deliberate when we make those choices to have deliberate inconsistencies. Otherwise when a user is looking at the different content entity types and they all look almost identical without any cue that person is lost.
So blocks are not standalone, blocks were never been designed to be viewed independently, they are placed into other entities. The main use case is with Layout Builder, currently there is no way to preview a block before adding it to a layout. Blocks are only viewable by authenticated users with with necessary permissions, that means the URL (for example
/admin/content/block/1) is appropriate, that also means blocks should remain under/admin, that means the permissions are appropriate, so in consequence the "Standalone Block Content URL" would be obsolete. Blocks could only be previewed by users that are able to edit blocks while anonymous users or users without the necessary permission get an access denied page. That lead into the following conclusions:Block Content settingspage again. Instead make that option (the tab) enabled per default for every block type for users with the necessary permission. The tab should be renamed toPreview, view you associate with viewing something in its final form, by making that deliberate switch in the wording we communicate you are able to preview something, but its final form will look different in a different surrounding context. And in regards of the preview it would be a reasonable step to use the admin themeClaroinstead of the default themeOliverorespecting the context of the/admin/content/block/path - using Olivero per default is waking wrong expectations as well as assumptions.I've removed the
Needs usability reviewtag and changed the status back toNeeds workComment #55
xjmI just filed #3455803: Block library view links to the edit page for each content block even when the user does not have edit access which may be a duplicate. This issue has wider scope, but would resolve that.
May check back later to incorporate my STR into this issue etc. and properly close it as a duplicate.
Comment #56
acbramley commentedRe #54
Thanks for the detailed write-up, lots of great insight in there.
As a subsystem maintainer of block_content I'm a little on the fence on whether this feature should be in core. As you say, blocks aren't really designed to be rendered by themselves. However, I have implemented this exact thing for a client who wanted to be able to see a rough idea of what the block would look like on a dedicated page.
Responding to some of the feedback:
I don't think Preview fits here either, and may be confusing for some users. We have a Preview button on Nodes which takes you to an unsaved version of the Node and allows navigating back to the edit form without losing changes.
If we have a Preview tab for Block content, users may confuse this functionality and click on the tab which would effectively lose their changes in the form.
I think this would defeat the purpose of the feature for a lot of users as the block would look nothing like what it is going to look like in the Layout Builder or Block plugin context. It should be in the frontend theme.
Comment #57
smustgrave commentedThinking of picking this one back up but before I do are we convinced it will be merged? When I opened this recipes weren’t a think
https://www.drupal.org/project/block_content_template
Is still around
Comment #58
smustgrave commentedSo discussed this with the other block_content maintainers and this may be too much an edge case. Does this hit 80% of users?
Comment #59
dpiI'd imagine this would be just as useful as the media route.
So long as the media view route config option exists in core, this feature should still be viable.
In the same manner, having a view block/media content route would-have-been/is useful in a handful of occurrences as an end user feature or for debugging purposes.
Comment #61
smustgrave commentedUnassigning myself but think we should still try and land this one.
Comment #64
smustgrave commentedStarted a new MR but still not 100% if this will ever be accepted into core, no longer