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

View page

view

API changes

Block content now has a settings form with one setting for enabling standalone URLs.

Data model changes

NA

Release notes snippet

TBD

Issue fork drupal-3342998

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

smustgrave created an issue. See original summary.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

smustgrave’s picture

Issue summary: View changes
smustgrave’s picture

So 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.

smustgrave’s picture

Status: Active » Needs review
larowlan’s picture

Status: Needs review » Needs work

Left some more feedback on the MR

larowlan’s picture

andyf’s picture

Thanks 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?

smustgrave’s picture

This 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

smustgrave’s picture

Status: Needs work » Needs review

Addressed the feedback. Ready for another review

andyf’s picture

This 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

Thanks for humoring me @smustgrave, that wasn't clear to me when looking at the IS and description of the linked module.

larowlan’s picture

Status: Needs review » Needs work

Just one minor thing and one question, left in the MR

smustgrave’s picture

Status: Needs work » Needs review

Addressed feedback

wim leers’s picture

Issue tags: +Needs screenshots
smustgrave’s picture

Status: Needs review » Needs work

Seems removing that render key caused some failures. Need to investigate why.

smustgrave’s picture

Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new185.22 KB
new79.08 KB

Lets see if that works.

smustgrave’s picture

Fixed!

@Wim Leers I added some screenshots those work?

wim leers’s picture

Ah … 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? 🤔

smustgrave’s picture

Title: Add standard template for block content » Add view tab + standard template for block content
Issue summary: View changes
Issue tags: -Needs issue summary update

Updated will update the template too!

smustgrave’s picture

Left a small in the template.

larowlan’s picture

Left a comment on the MR

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new90 bytes

The 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.

smustgrave’s picture

Status: Needs work » Needs review

Rebased

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new5.86 KB

The 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.

smustgrave’s picture

Status: Needs work » Needs review
needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new5.86 KB

The 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.

smustgrave’s picture

Status: Needs work » Needs review
larowlan’s picture

Still keen to understand why we need to manually add the list cache tag

smustgrave’s picture

Odd so removing that line worked now. No clue but I'll take it.

larowlan’s picture

Status: Needs review » Reviewed & tested by the community

This looks good to me, thanks @smustgrave

lauriii’s picture

Status: Reviewed & tested by the community » Postponed (maintainer needs more info)
Issue tags: +Needs issue summary update

What'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.

smustgrave’s picture

Status: Postponed (maintainer needs more info) » Needs work

Think 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.

smustgrave’s picture

Issue summary: View changes
Status: Needs work » Needs review
Issue tags: -Needs issue summary update

Updated 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.

larowlan’s picture

Status: Needs review » Needs work

Left a review

rkoller’s picture

I'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.

smustgrave’s picture

Addressed 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.

rkoller’s picture

i 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).

smustgrave’s picture

Well 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.

rkoller’s picture

well 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?

smustgrave’s picture

Create a new section for "Block" @larowlan some of the stuff requested we remove would break existing behavior.

smustgrave’s picture

Status: Needs work » Needs review

Feedback addressed

acbramley’s picture

Status: Needs review » Needs work

Needs a reroll

smustgrave’s picture

Assigned: Unassigned » smustgrave

Will address it tomorrow!

smustgrave’s picture

Status: Needs work » Needs review

Resolved all feedback. Still passing.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new90 bytes

The 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.

smustgrave’s picture

Status: Needs work » Needs review

Rebased

smustgrave’s picture

Addressed feedback.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new90 bytes

The 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.

smustgrave’s picture

Status: Needs work » Needs review

Rebased

larowlan’s picture

Issue tags: +Needs usability review

From #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

rkoller’s picture

i 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 Block is created with only a single page Block Content Settings in it and that single page has only a single interface component, a checkbox Standalone Block Content URL on 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.

rkoller’s picture

Status: Needs review » Needs work
Issue tags: -Needs usability review

Usability 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 description link: /admin/content/block/1
Operations Edit button: /admin/content/block/1

MR applied - "Standalone Block Content URL" and "Standalone media URL" ticked
Block description link: /admin/content/block/1 (uses Olivero)
Operations Edit button: /admin/content/block/1/edit (uses Claro)

Accessing /admin/content/block/1 as an anonymous user in a private browser window leads to an Access denied page in Olivero.

Media name link: /media/1 (uses Olivero)
Operations Edit button: /media/1/edit (uses Claro)

Accessing /media/1 as 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/1 redirects to /admin/content/block/1/edit
/media/1 redirects to a Page not found page

One 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 image and 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:

  1. There was a clear consensus to recommend removing the Block Content settings page 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 to Preview, 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 theme Claro instead of the default theme Olivero respecting the context of the /admin/content/block/ path - using Olivero per default is waking wrong expectations as well as assumptions.
  2. One suggestion that is completely out the scope for this issue, which could be moved to a followup issue is to add an option on a per block type basis on the edit page to set in which theme the blocks of a block type are previewed in. Meaning the user would be able to change the preview from the default Claro to the default theme for example. That way the user would be flexible to assign a block type to the context aka theme it is created for.
  3. The last point that was raised was in regards of consistency, it was suggested to add a publishing option for blocks. But while writing up the issue I've remembered and after some searching I've found that there is already a far grown issue for suggestion: #2834546: UI for publishing/unpublishing block_content blocks. So a double thumbs up for the issue and feature from the group.

I've removed the Needs usability review tag and changed the status back to Needs work

xjm’s picture

I 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.

acbramley’s picture

Re #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:

The tab should be renamed to Preview, view you associate with viewing something in its final form

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.

And in regards of the preview it would be a reasonable step to use the admin theme Claro instead of the default theme Olivero respecting the context of the /admin/content/block/ path - using Olivero per default is waking wrong expectations as well as assumptions.

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.

smustgrave’s picture

Thinking 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

smustgrave’s picture

Status: Needs work » Postponed (maintainer needs more info)

So discussed this with the other block_content maintainers and this may be too much an edge case. Does this hit 80% of users?

dpi’s picture

I'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.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

smustgrave’s picture

Assigned: smustgrave » Unassigned
Status: Postponed (maintainer needs more info) » Needs work

Unassigning myself but think we should still try and land this one.

smustgrave’s picture

Started a new MR but still not 100% if this will ever be accepted into core, no longer