?
avatar AndySDH
AndySDH
16 Sep 2020

Problem identified

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

Open questions

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!

avatar AndySDH AndySDH - open - 16 Sep 2020
avatar joomla-cms-bot joomla-cms-bot - change - 16 Sep 2020
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 16 Sep 2020
avatar AndySDH AndySDH - change - 16 Sep 2020
The description was changed
avatar AndySDH AndySDH - edited - 16 Sep 2020
avatar AndySDH AndySDH - change - 16 Sep 2020
The description was changed
avatar AndySDH AndySDH - edited - 16 Sep 2020
avatar brianteeman
brianteeman - comment - 16 Sep 2020

I believe the reason was that category has two default layouts - category and list

avatar Bakual
Bakual - comment - 16 Sep 2020

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.

avatar AndySDH
AndySDH - comment - 16 Sep 2020

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.

avatar Bakual
Bakual - comment - 16 Sep 2020

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.

avatar AndySDH
AndySDH - comment - 16 Sep 2020

Oh I see what you mean. So the difference on whether the layout is in the URL or not, is based on whether there's a XML file or not, if I understand correctly? If so, I see, good to have some clarity :) @Bakual

avatar Bakual
Bakual - comment - 16 Sep 2020

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.

avatar AndySDH AndySDH - change - 16 Sep 2020
Status New Closed
Closed_Date 0000-00-00 00:00:00 2020-09-16 14:19:31
Closed_By AndySDH
avatar AndySDH
AndySDH - comment - 16 Sep 2020

Awesome, thanks for the clarification, I'll close this :)

avatar AndySDH AndySDH - close - 16 Sep 2020

Add a Comment

Login with GitHub to post a comment