I can see there's an option to choose a layout:

enter image description here

How can I add new custom layout with template override?

I have tried several way for eg. html/layouts/mylayout.php, html/com_content/category/default_mylayout.php. But none is working. So, how should I do?


With that "Choose a Layout" option in a menu item of type "Category Blog" you can specify what article layout to use for the individual articles from that category blog when you visit them individually.

Add your article layout file default_mylayout.php + the xml file default_mylayout.xml to the folder: /templates/your-template/html/com_content/article/.

After that the article layout for the individual category blog articles should be available in that "Choose a Layout" dropdown selection.

  • This is correct if you want to choose the article layout. If you want to change the blog layout then you need to either do an override or a new menu item like @Arlen has shown. Effectively the same as @pe7er but instead of the menu structure ending in article you use templates/your-template/html/com_content/category/. Don't forget to use the XML which you can copy from components/com_content/category/default.xml then when you add a new menu item you will see your menu item is also there. – Eoin Jun 13 '20 at 22:34

You need to add a xml file along with the php file.

Check out the docs : https://docs.joomla.org/Layout_Overrides_in_Joomla

  • the link din't help me – Bhojendra Rauniyar Dec 21 '18 at 14:40
  • Please try to rename your files. mylayout.php to mylayout_blog.php mylayout_blog.xml – mixahlos Dec 21 '18 at 14:46
  • not working.... – Bhojendra Rauniyar Dec 21 '18 at 14:57

You have a problem. From the first screenshot up there it looks like you're looking to set a layout on a menu item type "Articles - Category Blog"

The problem is, that's already a layout. You can't stuff two values in the layout parameter. The only thing you can really choose in that particular case is whether to use the template override for the category blog layout (template/html/com_content/article/blog.php) or the original, or one in one of the other templates (essentially selecting whether the layout will be "blog" or "templatename:blog").

If what you're looking to do is create a new layout that's kinda/sorta the blog, you have to create it as a menu item in its own right. But you'll still run into an issue. The com_content component's category view code is hard-coded to do certain things when the layout is 'blog' that will not get done for any other layout. (Yes it was a Bad Idea to do that. It was jaw-droppingly, mind-bendingly bad, in fact. But apparently no one was about to let a silly thing like excessively tight coupling stop them from implementing it.)

So again, if your goal is to create a layout using the data for the category blog layout, you either have to do a template override of that core layout or consign yourself to essentially writing -- and maintaining -- a portion of the view in your template code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.