Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
yoroy should be credited in any commit for this issue.
Spinning off a more actionable part of #1957276: Let users set the block instance title for Views blocks in the Block UI since that issue is going to be a lot harder to solve.
- Views blocks currently do not provide the user with any indication of what their title is.
- Views blocks do not provide a default machine name.
- Views blocks do not indicate that the primary way to set the title is via Views.
- The logic that generates Views titles is dynamic.
- There are usability concerns with potentially allowing the user to override the View title through the Block UI when the user normally sets it in Views.
- The Block system having a say in what the view title is complicates things architecturally.
- #1957214: Title setting in views UI does not indicate when the title might be overridden is also going to be tough to solve in a robust and maintainable way.
Proposed resolution
Let's start with something we can all at least live with.
- Provide a message to the user in the Block UI that the title is set with Views, and provide a link to edit the view.
- Indicate that the title is dynamic.
- Provide a default label and machine name.
- Continue to allow the "Display title" checkbox on the block instance to control title visibility. (Views already respects it in HEAD.)
- Either:
- Disable the label field and set it to the view title, or to the view name if there is no view title. (Followup: Should views use the same "title required but can be hidden" logic blocks and panels do?) Or:
- Provide a label field that defaults to the above. Do not disable it, but also add a message indicating that this field does not actually control the title the view displays, but only provides an administrative label.
There are problems with both 1 and 2, but 2 seemed more confusing overall, so I went with 1 in the attached patch.
Remaining tasks
- Decide if this approach is an acceptable compromise. (It's certainly better than what we have.)
- Discuss the default value for the block title field, and whether it should be disabled or not.
- This definitely deserves good test coverage for all the various combinations of view and block configurations.
Comment | File | Size | Author |
---|---|---|---|
#14 | what_the_no_results_block_looks_like.png | 11.78 KB | xjm |
#14 | what_the_arg_block_looks_like.png | 11.01 KB | xjm |
#14 | executing_the_display.png | 19.7 KB | xjm |
#14 | block_with_default_arg_executed.png | 12.55 KB | xjm |
#14 | not_executing_the_display.png | 12.97 KB | xjm |
Comments
Comment #1
xjmThe
empty()
check is a leftover from earlier logic. I'll remove it in the next reroll.I dunno if there is a better way to get the edit URL for the display than concatenating like this?
Silly parens are silly.
Comment #1.0
xjmUpdated issue summary.
Comment #1.1
xjmUpdated issue summary.
Comment #1.2
xjmUpdated issue summary.
Comment #1.3
xjmUpdated issue summary.
Comment #2
xjmThis could actually probably just be an
l()
, since the whole string is the link value, not just part of it.Comment #2.0
xjmUpdated issue summary.
Comment #2.1
xjm.
Comment #3
Bojhan CreditAttribution: Bojhan commentedJust wondering, what does this display when I have a argument in my title? Should this not use tokens?
Comment #5
xjmTurns out, this is actually really complicated to calculate, because any number of things can override it. See in #1957214: Title setting in views UI does not indicate when the title might be overridden. In the meanwhile, as a first step, this will just use the title the View returns.
Comment #6
xjmApparently this doesn't work in 5.3. :) Fixing.
Comment #7
dawehnerI guess for everything which needs dynamic stuff (like arguments etc.) executing the view certainly does not help. I guess we should just call getTitle() (withote executing it) and let it fetch the Title configured in the display. This also improves performance.
Directly using the function result is just possible in php 5.4: http://www.php.net/manual/en/migration54.new-features.php
Comment #8
xjmComment #9
xjmOops, crossposted. @dawehner, is this all you mean?
Comment #11
dawehner#9: views-block-1967460-8.patch queued for re-testing.
Comment #13
xjmRight, that test. Writing actual tests later. We need a lot more than the "is disabled" equivalent of this one assertion now. :)
Would love some reviews on the functionality (both code and user interaction) before I go crazy codifying it in SimpleTest, also. I'm not looking for perfect; I'm looking for "make a major UX regression into at least just a minor one."
Comment #14
xjmSo here's the implications of executing the display or not. I'd actually prefer to execute it, to get a more meaningful title more of the time. We can always remove it if we get some fancy title pattern logic later.
We have these two blocks with dynamic titles: The first one has the title set as a no results behavior; the second sets it based on a default argument.
Here's what placing a new instance of these blocks looks like if there's no site content/other argument if the display is executed:
Here's what they look like if the display is not executed:
Comment #15
xjm@timplunkett and I just came up with yet another way of solving this. Another darn issue incoming shortly. :)
Comment #16
xjmAlternate solution: #1968296: Block title != view title
Comment #17
damiankloip CreditAttribution: damiankloip commentedI will check out the other issue, but I would say this in it's current form is a no go.
This would set the machine name of a block based on the current context - which seems bad. So if the view was currently empty your machine name could be 'Sorry, no results' from a title override or 'User %1' from an argument but obviously that is a very dynamic thing.
Are we thinking the other issue is a better route forward now?
Comment #18
xjmI spent an hour on the phone with @webchick and @effulgentsia talking about this problem yesterday; just haven't gotten around to posting annoying iteration #5 and #6 yet. This one is wontfix.
Comment #19
dawehnerCan't we instead of open new issues and then close and then open another one, just think about a proper solution first, in the open.
Comment #20
xjmSorry, never saw your reply @dawehner -- we are back to #1957276: Let users set the block instance title for Views blocks in the Block UI.
Comment #20.0
xjmUpdated issue summary.