3

OK so I'm trying to create an alternative menu item layout and it doesn't seem to be working. I'm using the latest version of Joomla 2.5. What I did:

  • created folder structure: mytemplate/html/com_content/categories/
  • copied default categories view files from components/com_content/views/categories/tmpl/ and renamed them to features.php, features.xml, features_items.php
  • changed the title in features.xml

When I change something in features.php or features_items.php it doesn't work but if I rename them to default or if I just change the core files then it works. Does anyone have any idea why this doesn't appear to be working? I know about the priority thing that says that menu layouts will override the article and category layouts but this isn't a category layout, it's a part of the content component that just lists categories. Also, I've noticed that if I change the layout for a specific category then it actually overrides the menu layout so the priority doesn't apply then.

Am I doing something wrong or how can I create an alternative layout for this particular component part?

2 Answers 2

1

What you are doing should work, and your folder/file structure looks fine. I just tested it in Joomla 2.5. The name you entered in your XML file should appear as a new Menu Item Type:

Custom categories layout

XML file (part)

<?xml version="1.0" encoding="utf-8"?>
<metadata>
    <layout title="Custom Categories view" option="This view is created with an override">
        <help
            key = "JHELP_MENUS_MENU_ITEM_ARTICLE_CATEGORIES"
        />
        <message>
            This view is created with an override
        </message>
    </layout>
    ....

There are a couple of errors you can look for:

  • Make sure all files use the same name scheme (features or feature)
  • Check that you have copied the correct files from the correct folder (components\com_content\views\categories, not components\com_content\views\category
  • Make sure the XML file contains a unique name.
5
  • Hey, thanks a lot for the answer! I just copied the default XML file and just changed the title in it, maybe that's why it won't work? I'll try in a second and I'll report back if it worked. I've checked for the kind of errors you've mentioned and it seems they're all okay.
    – serge
    Sep 9, 2014 at 22:17
  • I've tried with a simple XML file but it doesn't seem to be working :(
    – serge
    Sep 9, 2014 at 23:51
  • What exactly isn't working? Does the custom view you're creating show up in the Menu Item Type selector (see image above)? Are the overrides not displayed? Do you see any error messages?
    – johanpw
    Sep 10, 2014 at 0:11
  • The custom view is showing up in the Menu Item Type Selector, but the overrides are not working, I've deleted everything in the features.php file just to test and nothing happened, the default view loaded anyway :(
    – serge
    Sep 10, 2014 at 0:49
  • I did some testing, and you're right, it doesn't seem to work properly. This is the link I get for the menu item when I create an override called "test": http://mysite.com/index.php?option=com_content&view=categories&layout=MYTEMPLATE:test. I'm not sure why, but if I remove the part that says MYTEMPLATE: (leaving &layout=test), the override seems to work. Maybe it gives you a push in the right direction.
    – johanpw
    Sep 10, 2014 at 2:29
0

In order to override the default.php layout, the files in the HTML folder need to be named the same as the ones you want to override. You can't override the XML file, only the php files.

2
  • Already tried that I've said it in the question, the thing is I don't want to override it but create an alternative layout for it :) Hope you understand.
    – serge
    Sep 9, 2014 at 20:48
  • Correction, you can only override the view PHP file, nothing else ;)
    – Lodder
    Nov 4, 2014 at 16:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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