Not an actual "issue" but more of a question to understand why this works the way it does.
In Joomla, it seems that the handling of the &layout=
parameter is inconsistent across components or views.
For example, in com_content category view, the layout is actually appended to the URL like: &layout=blog
.
This can also be manually overridden in the URL by manually adding &layout=...
to change the layout.
But, still in com_content, but in article view, the layout is NOT appended to the URL. It is selected in the menu item, but it acts as a hidden parameter that is not seen in the URL, and cannot be overridden/added manually either with &layout=...
, it won't have any effect.
The same behavior applies to com_contact. The layout of contacts can be chosen in the menu item, but it is not shown in the URL and cannot be added to the URL
My question is simply: what is the reason behind this inconsistency? I'm not necessarily saying it's wrong or a bug, just wondering about the inconsistency.
I've also looked at components/com_content/helpers/route.php - and it seems that there is a line like $link .= '&layout=' . $layout;
even for the article URL, but it seems like that's not really doing that. So this seems odd.
Anybody knows? :)
Thanks!
Labels |
Added:
?
|
By default, views try to load the layoutfile default.php
. If you want to load another layout, then you need to specify it. In the case of the category blog, it is specified in the URL as it comes from the menuitem.
It can also be specified in the parameters (eg article parameters), then you may not see it in the URL.
Oh I see the difference now.
So I'm guessing this is weird/ wrong? :
I've also looked at components/com_content/helpers/route.php - and it seems that there is a line like $link .= '&layout=' . $layout; even for the article URL, but it seems like that's not really doing that. So this seems odd.
No, it's not wrong. It works for articles as well. Just not when you've set an alternative layout in the parameters (I guess, haven't checked). If you eg have an alternative menuitem for articles (a separate layout AND xml file), then you will see the layout=xyz also in the URL like for the category blog layout.
If there is an layout XML, then the layout is part of the menuitem URL (omitted if default), yes.
If it's just a parameter, it usually doesn't end up in the URL as the code in the component will change the layout.
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2020-09-16 14:19:31 |
Closed_By | ⇒ | AndySDH |
Awesome, thanks for the clarification, I'll close this :)
I believe the reason was that category has two default layouts - category and list