New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[UX] Using * or % as a wildcard in layout paths does not have expected behavior #1602
[UX] Using * or % as a wildcard in layout paths does not have expected behavior #1602
Comments
I am wondering whether it may be necessary to also positively exclude results/* on the standard layout? I feel sure I have done something similar and will check. |
Ah no, of course, you have to use % not * as the wildcard. |
My fault - email report was wrong, I actually used % as a wildcard, it doesn't work. |
I think part of the problem is that people expect both the placeholder ( |
Here's a use-case that was reported via e-mail as having trouble:
I think the only current solution for this is to have three different layouts, one at I tried to set up a single layout at |
Needing multiple layouts for multiple paths sounds like a shortcoming in layouts, so I have created #1671 |
"Here's a use-case that was reported via e-mail as having trouble:" But... I'm still confused as to why there is also a "path" in "Add visibility condition"... ?? |
👍 I would have done it if you haven't beaten me to it. |
I've started a solution for this and here documenting my thoughts: Background If you visit But entity load paths (such as So what this PR attempts to do is to breakdown a path passed to
So if a person visits path
Need to do more on the cascading of these paths. Also, related, a path Would be good to consider as well matching by aliases, but perhaps another PR. |
I suspect that everyone is likely confusing a
This confusion is happening because in the Layout UI the description text on that field actually says that the I don't think that we should expand the meaning of of I'd prefer to re-do that field to use a star instead of the percent, and then do all the expected checking, as though it were a true wildcard (as explained in the previous comment - but with @docwilmot would it be had to adjust the above to use a star instead of a percent? |
Not so sure about this. Fact is everyone may be "confused" because a % symbol seems intuitive for this purpose. I think conversely adding a new cryptic symbol is more confusing. Right now to the end user Would welcome more opinions. |
Yes! This is exactly my point :) We added a Now everyone thinks the The proposed suggestion above changes how it behaves so that it would behave more like a I think it will make things even more confusing if we have two different symbols that do the same thing. If we do this, people will wonder why a wildcard is represented by a
Exactly! But what "a path that starts with 'node' followed by any two things" should really be is
I'd rather Backdrop handle the context stuff in the background without people needing to understand the difference between a |
I understand all of this, but point is we already have the %.
|
Any path that has an Is this possible right now? IIRC we can only do the pre-defined paths at |
So are you proposing we change the symbol used in layouts totally to an asterisk? |
Yes. If we're going to change it to work like an asterisk (which I think we should -- that's what people expect) then it should be an asterisk. |
Interesting: seems @jenlampton makes more sense after a 9-month break and two cups of coffee: I agree wholeheartedly with your recommendation now ma'am. Well played. 😃 |
There's still a difference between placeholders (%) and wildcards (*), though; it might be useful to maintain the distinction.
So how about supporting them both in layout paths, but with the proviso that you can't mix And then maybe a "more info" link or tooltip could help explain to newcomers what the distinction is and why one would choose one over the other. |
The wildcard should be able to handle the use-case for the placeholder too.
We might still have to support both to make this change in a way that is backwards-compatible, though I'd still prefer not to. |
Ah. If we only use |
I agree with that! The "%" placeholders mean something different (to me). Keep in mind, that % has a special meaning in hook_menu(). Think of "%node", which loads the node object. That's something totally different than "node/*" which translates to paths like "node/1", "node/2", ... "node/749". Using "%" and "*" as equivalent might cause more confusion, a placeholder that loads an object is not the same as a wildcard on paths. |
No, they're complementary. The layout URL paths field expands the situations in which a layout can be used (when you add an entry, the layout works on more paths); the visibility URL paths field narrows the situations (when you add a visibility condition, it reduces the number of paths the layout could apply to). And that's the case for both normal paths and alias paths. In particular, the layout URL paths field lets you apply the layout to multiple unrelated menu router paths, like
I couldn't think of any situation where one would use an alias in a layout URL path that couldn't be reproduced by using just normal paths there and visibility conditions that involved aliases. But my motivation for including aliases was that visibility conditions on layouts and blocks based on URL paths accepted both normal paths and aliases, and I thought that to preserve the consistent "mental model," layout URL paths should, too. |
That's the behavior of the "Alternative paths" field that Layout Wildcard adds to the layout; it only handles normal paths, not aliases. |
Sorry, I didn't write that clearly. The "URL Paths" field definitely expands the paths that the layout matches. I meant to say that when using aliases within the field, it works the same as visibility condition. Using internal paths expands the places the layout is applied, but specifying aliases will always only reduce the places it's used. |
I'm sorry, but that's not the case, and I've put a counterexample in the Tugboat sandbox.
Admittedly this is a somewhat contrived example, contrived to address this particular point. I can certainly see the argument that accepting aliases in this field is unnecessary because the same outcome could be obtained by other means. But I don't see how adding an alias to that field could "reduce the places [the layout] is used." |
Hi @bugfolder - l've tested this and I like it. I've always found it weird that the layout paths were nearly all |
Having seen generally positive comments about the "URL paths" PR and its approach, I'm going to move on to the missing item I mentioned above: the problem of layout ordering when URL paths are in effect. To give a concrete example, suppose we have two primary paths and three layouts:
In the absence of URL paths, with the normal ordering of layouts, if the request path is If we turn on URL paths, then if the request path is Currently, within a primary path, the layouts can be reordered. So one could imagine letting one impose an overall global order on layouts, rather than grouping them by primary path. So, for example, if we wanted layout 3 to be considered first, we might end up with this:
However, breaking up the grouping by primary path seems like it would introduce confusion, since the benefits of grouping would be lost for everyone, but only the (minority of?) people who use URL paths would benefit from this global ordering. So, the thing I'm leaning toward is adding a second field to each layout, "URL paths weight", whose default value is 0. A non-zero value of URL path weight would override the ordering, and a nonzero/non-empty value would only be allowed if the URL paths field is non-empty. That is, since only URL paths break normal ordering, only non-empty URL paths get to take advantage of URL paths weight. So then one could do something like this:
And this setting would then allow layout 3 to be considered first with request path And yes, that would allow users to do self-foot-shooting by doing pathological things like
where now they've just overridden an ordering by using URL path weights when they could have just reordered the layouts under the path in the usual way. We could address that with some warning on the field instructions: "Don't mess with this unless you're sure of what you're doing." I suspect the vast majority of use cases wouldn't need to use weights, since it seems very rare that someone would have multiple competing layouts with the same URL paths where ordering would matter. The current PR displays the URL paths on the layout listing page. We'd also list the URL paths weight (if nonzero) so that (again) the user can tell most of what's going on in terms of layout path matching and ordering from what's shown on the layout listing page. So how does that sound? |
Summary of two points discussed in the Weekly Design/UX meeting:
|
Well, one of the most common use cases for me is a views path that has arguments (I use String passthrough in the Layout). I was looking forward to this being in core, since I want to use the same layout for several related views that use the same arguments but have different URLs. This decision essentially precludes this use case (which I want to believe is pretty common?). |
Hmm, that use case is good to know about, so maybe we should reconsider that decision. Or think about finding an intermediate case between "no placeholders" and "placeholders that result in specific object contexts." Certainly string pass-throughs would be pretty innocuous. That comes back to one of the ideas I mentioned in the meeting: have a setting in the layout that says "allow placeholders, and I promise to configure URL paths so that the layout will only be used on paths that have placeholders in the right place." Meanwhile, I've updated the PR per the above, and also made some UX changes (improvements, I hope), which I'll lay out in the next comment. |
This scenario, comment #1602 (comment), I would imagine should be quite unusual. I imagine if you really want path |
Yes, I'm dropping the "url path weights" idea for that reason. Thanks for the F/B! I do have a new iteration in progress, hope to have something to post fairly soon. |
The scenario that @argiepiano describes above sounds common enough that it seems like it should be accommodated "out of the box" with this PR. So I've restored URL path matching for menu router paths that have placeholders, but enforce that the load functions (if any) must match between the router item of the layout path and the router item of the request path. As I was trying this out for various scenarios, I found that a not-uncommon hack for making URL paths useful for paths with incompatible load functions (like As an example of its utility, if you create a layout with primary path So URL paths make layouts pretty powerful, but as much as we strive to make things discoverable from within the admin website UI (and I've added a lot of conditional explanation there), there really needs to be some extensive documentation for the whole story. So I've written a documentation page, intended to go on the docs site (which would be linked from the website UI). For now, I'm attaching it to this comment. Please read through it. It includes examples of several scenarios that I think would be common use cases. (If you can think of other use cases that should be addressed and/or explained, please add them.) There is the beginnings of an automated test helper module, "Layout URL Paths Tests", which is (temporarily) not hidden; if you enable it, you can see the four examples described in the documentation. The PR is updated (and rebased); please give it a whirl. |
I don't understand how these two things are related. The menu router paths for these views page displays do not have placeholders. What am I missing? |
That those menu router paths do indeed have placeholders. Try this. Create a View with a contextual filter whose page path is The use case that @argiepiano describes is the case "A dynamic View with multiple page displays" described in the documentation document. |
Note from today's meeting: it would be nice to give instant feedback, or instant in-place correction, if someone tries to use a "*" in the layout's primary path (or, for that matter, tries to use a "%" in the URL paths field). Another comment from today's meeting: a suggestion that a UI akin to Context's popup dialog for adding additional paths one-at-a-time (rather than a textarea field like URL paths in visibility conditions) might be preferable. (H/T @quicksketch.) |
I don't think I've ever done this. Do you just put the percent symbol in the "Path" field on the page display? (and also, why would you ever do this? Is this an 80% use-case?) To test, I created a views page display normally, and added contextual filters. The path I used was
Yes, I saw that and added it into the description of this ticket also. But as I said, there were no placeholders in the |
Hi @jenlampton it's on the site that you worked on before me. It uses it for different taxonomy filters. For example |
@yorkshire-pudding But adding a % at the end of the path is completely unnecessary for views contextual filters... so why do people do it? Is it a mistake, or is there a use-case? Or, maybe it's a left-over from previous versions of Drupal? Maybe it's just a habit? (I'm going back and looking at some of my older Drupal 7 sites -- upgraded from Drupal 5 or6 -- to see if I can find any examples of this) |
I've done it for years in D7, and it's on my main live site. For example, I have a node type of "Class", which has fields of "Year" and "Season", and there is a View that provides a listing of classes at, for example, path And yes, you put a '%' in the page path of the menu item for each of the Views contextual filter arguments.
Well, it's all over Views in core. Do a search for I also solicit @argiepiano to say more about his use case(s). |
Does this PR actually enable wildcards (*) now? I dont see how it would. And its not working in the sandbox. |
Sorry, I've been busy and not paying much attention here. It's true that you don't really need placeholders in Views paths when you are dealing with paths that contain contextual filter(s) as the last parts of the path (placeholders not needed in the views path for |
It does, and it's working in the sandbox (at least, for the documented cases). I enabled the test module that creates the use cases referred to in the documentation. I see you (or someone) has created a layout-created page that overrides another layout-created page (and so they're both listed as layout-created pages in the listing). That's a use case I hadn't considered, and that we briefly touched on the design meeting. I think the consensus there is that this is a case that ought to be supported, and so the PR will need to be updated to handle that case. And also the case of a View with contextual filters that don't include placeholders. (After all these years, I'd just assumed you needed the placeholders and so had always used them.) |
And in pondering how to handle this...the reason I didn't originally allow layout-created pages (LCPs) to be used to override other non-layout-created pages via URL paths was that the former don't have the "Main content" block, and I thought it would be really confusing for a user to create a LCP, give it a URL path of So maybe the right behavior is that LCPs with URL paths can only override other LCPs. But then that means more quirks that need to get documented in the documentation. (Maybe it's best instead to stuff all the functionality into Layout Wildcard module, and let the resolution of this issue go back to its original title: do instant-feedback/correction if a user tries to use a |
This issue has become so complex because we're trying to add:
I believe the last two tasks had previous issues somewhere. This issue started for the first task. Maybe we should tackle fewer than 3 at a time? If this gets bogged down I'd recommend we tackle the 2nd task first (I think that might be the more complex UI and API task), then come back to this one. |
bug report from email:
Most users would expect that entering a path with an asterisk into the layout path field would function as though a second "default" layout were created that applied to all pages under that path. Is there any way we can make this happen automatically when someone enters an asterisk?
This issue has grown in scope considerably since it was originally opened. Documenting potential use-cases for shared layouts here:
I want different Layout Pages to use the same configuration. I have three stand-alone "layout pages" at
/modules
,/themes
and/layouts
on backdropcms.org. These pages are identical, with the exception of a single block in the content area. I would like to manage these pages as a single "Layout" with three blocks in the content area, with each block using visibility conditions. (Technically: this layout would be responsible for three menu router config files, but only a single layout config file.)I want several Views Page Displays to use the same layout I have three views page displays at
/foo
,/bar
, and/baz
that all have different content in the "content" area, but I want them to share the same blocks everywhere else. (Technically, This layout is responsible for zero menu router config files, and only a single layout config file)I want several Views Page Displays with contextual filters to use the same layout I have three views page displays at
/foo/%
,/bar/%
, and/baz/%
that all have different content in the "content" area, but I want them to share the same blocks everywhere else. (Technically, This layout is responsible for zero menu router config files, and only a single layout config file) --- The context on these three pages is always a string pass-through (never an object like user, node, or term) so will not present a problem.I want all my 'user' pages to use the same layout. I want my
user/login
,user/password
anduser/%
page to use the same layout. (Technically: this layout would be responsible for zero menu router config files, and only a single layout config file) -- The required user context for only one of these paths presents a problem.The text was updated successfully, but these errors were encountered: