backdrop-issues
backdrop-issues copied to clipboard
Allow 'Main Page Content' block to use a specific display mode
Description of the need If you add an Existing Content block to a layout, you have the option of selecting a specific display mode. This option is NOT available on the "Main Page Content" block and I think it should be.
A user just pointed this out in the forum: https://forum.backdropcms.org/forum/adding-and-using-custom-display-modes?page=0%2C0#comment-1888
Proposed solution
I assume that part of the problem is that the main page content is not always a node of a specific content types. Display modes are specific to content types. However, just as you can only select specific field blocks if you have a visibility condition that specifies a specific node type, we could only allow this option under the same circumstances.
@klonos makes this case here: https://github.com/backdrop/backdrop-issues/issues/3530#issuecomment-581105713
Alternatives that have been considered
https://github.com/backdrop/backdrop-issues/issues/3530
Additional information Add any other information or screenshots that would help.
I assume that part of the problem is that the main page content is not always a node of a specific content types.
yes, that's correct. The Main page content
block can contain output for for views, taxonomy terms, admin settings forms, and any other page callback. Most of these things have no idea what a display mode is, since display modes are specific to nodes.
However, just as you can only select specific field blocks if you have a visibility condition that specifies a specific node type, we could only allow this option under the same circumstances.
I don't see a parallel here...
Are you recommending that we remove the Main page content
block from the block listing (like we do with Field
blocks) for all pages that are not nodes? The Main page content
block is required in order to make all those other pages (views, terms, forms, etc) render correctly, so I don't think this is what you meant...
Or are you saying we add another block, which is an exact duplicate of the Existing content
block, but more restrictive, in that it only appears when the layout path you are on is node/%
, and will only display the node at that page? This we could do...
We could also improve the Existing content
block to allow it to pull the node ID from the path if the layout path you are on is node/%
... But I don't think this is what you meant either...
Can you be more specific about your proposed solution @stpaultim ?
I have no idea what the solution is, but my problem is this: I have a content type with a bunch of custom fields. Sometimes I want to display it one way with some of the fields and sometimes another way with different fields. So I add a display mode to the Content Type for each way. Then what?? There is no way to specify in Layouts which display mode to use. In Views, you get to choose the Display Mode, but not so in Layouts. Why Not?
There is no way to specify in Layouts which display mode to use.
The Full content
display mode (if enabled) is always the one used on the node/%
page. (Perhaps we need more documentation on this, or a clearer interface so this is more intuitive?)
If the Full content
display mode is disabled, the node/%
page will show the Default
display mode.

(This is exactly how Drupal 7 core worked, it's unchanged in Backdrop.)
@jenlampton - My suggestion was unclear and might not be practical from a technical point of view. Having said that, this is what I had in mind:
IF a user creates a layout with PATH = node/%
AND
If that layout has a visibility condition of Type = Post
THEN
The Main Page Content
block has an option to select which display mode to use.
In short I am suggesting that a goal of making it possible to select a display mode other than default.
The truth is that I had not 100% thought this through, because the CORRECT answer for this problem (as things stand) is probably (as @jenlampton suggests) to simply edit the default display mode and NOT try to change to a different display mode.
I am not sure that the problem here is a technical problem, rather it's conceptual problem. This solution (editing the default display mode) is obvious while your are building the site. But, let's say that you have created a site with 3 display modes and only after creating the third one, you decide that you would like the 3rd display mode to appear as the default display mode - there is the temptation to look for an option to switch which display mode is being shown rather than editing your default display mode.
If my proposal is not real difficult, I think it makes sense and would be a UI improvement.
As I think about it, one problem with my proposal is that this block setting depends upon layout conditions outside of the control of the block. What if the user later tried to change the path and/or visibility condition of the layout?
I suppose the idea of creating a new type of "content by display mode" block might be better. That would be a different request.
If my proposal is not real difficult...
The Main page content
block is a pass-through to the page callback from the menu item at every path. I'm fairly certain what you are asking for (altering the output of a menu callback) isn't possible at the block level. By the time the output gets here, it's already done rendering.
the CORRECT answer for this problem (as things stand) is probably (as @jenlampton suggests) to simply edit the default display mode
That's not exactly what I said :)
Every display mode, if not in use, will fall-back to using Default
so you're right that Default
will also work. But The correct(tm) solution to the problem is to enable the Full content
display mode, and use that one. The Full content
display mode will be used (automatically) on the node/%
path, as long as it is enabled. the Full content
display mode is hard-coded for this exact purpose in both Drupal 7 and Backdrop.
The code below, which uses the Full content
display mode, is from node_show()
which is called from the node_page_view()
menu callback for node/%
:
$nodes = node_view_multiple(array($node->nid => $node), 'full');
This is a place where we could add a global setting, if we needed one... But I'm not sure we do. I think if everyone knew that this is already how it worked, we would not end up with this feature request in the first place :)
This may be another one of those things that people who are very familiar with Drupal internals "just know" -- but it's completely non-intuitive from the UI alone. We need to do a better job of exposing this functionality so that it's clear which display mode will change what you see on node/%
.
This is not going to work.
As @jenlampton said that block just renders whatever page content is at a particular URL. If you go to admin/user
or node/edit
or special_callback
or config/development
the main content block just spits out what is supposed to be on that page. The idea of a view mode is completely useless on that kind of page.
We could also improve the
Existing content
block to allow it to pull the node ID from the path if the layout path you are on isnode/%
...
I think this feature would be very helpful. I was trying to work out if I could do this today.