Joomla-cms: Display articles as Category Blog template layout selecting issue

Created on 8 Feb 2018  路  12Comments  路  Source: joomla/joomla-cms

Steps to reproduce the issue

1) Add custom layouts:

  • templates/{template_name}/html/com_content/article/mycustomarticlelayout.php
  • templates/{template_name}/html/com_content/category/mycustomarcategoryblog.php

1) Create a a new menu item.
2) Select Article > Category Bloc
3) Look for an option to select view layout. There's only one, under: "Options" tab.
4) Click on "Choose a Layout", you will see a list of layout, but they are "Article" layout (i.e. mycustomarticlelayout). There is no option to select "mycustomarcategoryblog".
5) Pick a layout from the list (i.e. mycustomarticlelayout)

Expected result

To have the content displayed by a custom category blog layout (mycustomarcategoryblog.php).

Actual result

Always displayed by components/com_content/views/category/tmpl/blog.php

System information (as much as possible)

Joomla! 3.8.5

Additional comments

  • As developer, I am be able to add my own custom view layout for Category Blog display in my template, but it's not showing up for the content author to pick from.
  • As content author, I should be able t pick a layout to display Category Blog the way I want to, but I am not able to.
No Code Attached Yet

All 12 comments

Ian sure there are many other reports (and fixes) for this on the tracker.

Basically the current situation is that if you just create the layout as you have done them it is only available in the component and not the menu item. To make it available to select in the menu then you need to add an XML definition

Well, then, that will require override admin's com_menu, no?
And that wouldn't be practical.

Well, then, that will require override admin's com_menu, no?

No. The menu configs are already aware of scanning in template override directories for these XML files.

Except it doesn't do that now. Like I mentioned in the initial issue report:
Under "Options" Tab, when user clicks on "Choose a Layout", instead of seeing the list of layout from /templates/{template_name}/html/com_content/category/ it pulls from
/templates/{template_name}/html/com_content/article/

Because that "Choose a Layout" option is defining the layout for child articles from that menu item.

This part of the system is a little weird. When you choose a menu item type (in this case the category blog), the menu item defines a view and layout to be used and this part of the workflow isn't easily changed. So if you want the menu item to use your custom category layout, you need a mycustomarcategoryblog.xml file alongside your mycustomarcategoryblog.php file to define the menu item's configuration (you can copy components/com_content/views/category/blog.xml as the basis for this).

Okay, and that's at the template level, right?

Right. templates/{template_name}/html/com_content/category/mycustomarcategoryblog.xml and Joomla will pick up your layout as a new menu item type.

Thanks. Just tried and it works. Except: I no longer able to have multiple layouts for Category Blog. I tried with multiple custom layouts, and Joomla! picks the last layout.

I strongly encourage to put back the feature that developer can add multiple layouts and content author can pick based on that.

It basically killed Joomla's feature of multiple layouts for Category Blog.

You can image a case where I am using Joomla to host multiple sites:

  • Site A: I want my category blog layout to be "customlayout1"
  • Site B: I want my category blog layout to be "customlayout2"

Both Site A & B uses the same template. This wouldn't work, as of now.

If it's not letting you choose between multiple layouts that's a bug.

So long as you have customlayout1.php and customlayout1.xml together, that layout can be used as a menu item. Same for customlayout2, myotherlayout, or any other name.

What you probably can't have is multiple menu items with the translated name of "Category Blog". Which is probably expected behavior based on how the data arrays are keyed (same as a database, you can't have multiple items with the same key). So you'd need to use a different name for them.

Okay, thanks. It's working.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Didldu-Florian picture Didldu-Florian  路  4Comments

Shazrina1994 picture Shazrina1994  路  4Comments

joomleb picture joomleb  路  3Comments

brianteeman picture brianteeman  路  4Comments

tuts-22 picture tuts-22  路  5Comments