User tests: Successful: Unsuccessful:
As we know that with the release of Joomla 3.7 we have the Admin Menu Manager that lets you customise the administrator menu according to your needs. The backend menu comes in two flavours: Custom Menu and Preset Menu. You can have as many custom menu each configured in different way as suitable. Or if you do not want to customise then you use the Preset menu.
This PR is indented to extend the features for this Admin Menu Manager as promised in the initial strategy.
Custom Presets:
If you copy (and modify) one of the existing preset files from /administrator/com_menus/presets
to /administrator/templates/{your_template}/html/com_menus/presets
then you can use it as your own custom preset.
Import Preset Menu:
If you would like to modify merely one or two things and keep rest of the menu structure the same way as in a preset menu you still need to create all of those links one by one yourself manually. After this PR Joomla will allow you to directly import an existing preset (core or custom) into your custom admin menu directly and then you can customise it very quickly. When creating/editing a Menu
(menutype) you can optionally select a preset that you would like to import.
Export Menu as Preset:
You can also export your database driven custom admin menu
as an a Preset. Just select a Menu in the list and click Download As Preset
button in the toolbar.
Menu Module Layout Override:
The current implementation of the Admin Menu Module has the HTML rendering from within the PHP class JAdminCssMenu
which does not let you customise the HTML in any way. This PR puts all the HTML output logic into the layout files under tmpl/
folder as commonly expected. This way you can easily override the layout in your template.
Menu Structure Override:
Prior to Joomla 3.7 we could override the menu links using default_enabled.php
and default_disabled.php
. After the Menu Manager was introduced this ability was removed. Most likely you would really never need this anymore. It is always better to import a preset in a custom menu and customise it in the Menu Manager instead of messing with any PHP code. However, if you still insist, you can use the Custom Preset as discussed above. The naming convention is like my-custom-menu.xml
becomes My Custom Menu
(we can improve this later if needed). It is really easy to understand and work with. Give it a try.
Create a custom admin menu and set it as your active admin menu in the module settings.
Try to choose another preset in the module settings. The displayed menu should be updated according the selected preset.
Create a custom preset by copying (as discussed above) and make some changes. Set this custom preset as your active menu. The menu should now load you custom preset.
Create new custom admin menu and choose a preset to import. This should load the menu links and hierarchy from the preset.
From the list view of Menu, select one of your Admin Menus and click on "Download as Preset" button. The XML file should be downloaded correctly and should contain the selected menu links with correct settings.
I'd like to write the detailed documentation of the entire Admin Menu Manager. Please advise where should I head towards.
PS: As I am on a vacation this PR was created in hurry. Pardon me for any mistakes and please ask for any kind of clarifications or suggestions. I'll try to respond as quickly as possible.
Status | New | ⇒ | Pending |
Category | ⇒ | Administration com_admin com_menus Language & Strings Modules Libraries |
Labels |
Added:
?
?
|
Hello Izhar,
nice work done with a lot of effort. Thanks.
I am testing and will do some more testing.
I copied the full https://github.com/joomla/joomla-cms/tree/c787b79e6ae7a198087f9c72434856d3b6f63ee3 over an existing J 3.7.2 for testing.
I found an issue if you add a menu item to a new menu that is already existent maybe through automatically added menu or another custom menu. BE ends up white with error 1242.
The error message is: Subquery returns more than 1 row
To avoid this error there might be options like:
I got two other error messages after creating a new menu:
Notice: Undefined property: MenusViewMenus::$filterForm in /opt/lampp/htdocs/j36vm32/administrator/components/com_menus/layouts/joomla/searchtools/default/bar.php on line 37
Fatal error: Call to a member function getField() on null in /opt/lampp/htdocs/j36vm32/administrator/components/com_menus/layouts/joomla/searchtools/default/bar.php on line 37
I was distracted by some other work. After reloading the page, I guess, the menu appeared and I could not reproduce this. I will test this further in a while.
Method of import
On making a new menu "menunew" I can import the joomla.xml or modern.xml.
Example:
I import joomla.xml.
I check the menu, I don't like it.
I import modern.xml.
Now I have all the menu items from both imports.
Iit would be helpful to have an option to either add the new preset to the existing items or replace all existing items. So there is the possibility to add either a preset for only a component or a full menu.
New presets not showing
I placed a new XML file into administrator/components/com_menus/presets/, called menunew.xml.
This file is not showing up in my importable xml files in the menu edit. Placed it into the templates override folder like given above, and it also does not show.
File structure xml vs. php
One more thing about the new xml file structure. Before it was a php file (default_enabled.php), so template parameters could be imported and used as custom settings.
Template settings like minimal, normal, advanced. The user could choose his preferred way of displaying the menu. Lets say, have 2 menu items, 10 or 24, depending on what he needs for daily work or if he uses a small screen device or a desktop computer.
I guess with an xml file we could loose this simple way of changing the menu view.
Suggestion for mobile view
With an additional parameter viewlevel in the xml this could be done if the menu edit gets this too.
This would be a good feature for people who do a lot of their work with mobile devices. And it would kind of restore a possibility you had with php files before.
@StefanSTS Below are my responses as per my understanding to your inputs:
It would be helpful to have an option to either add the new preset to the existing items or replace all existing items...
If we replace all the existing menu items during a single click import process it would be an easy destructive action. Therefore, I omitted that feature on purpose. The user must "select all" and "delete" all existing menu items if so intended.
I placed a new XML file into ... not showing up in my importable xml files in the menu edit. Placed it into the templates override folder like given above, and it also does not show.
I tested this and it is working here as expected. I may be missing something, please let me know if you still get this issue.
File structure xml vs. php
The preset XML files are to represent the menu item definition and hierarchy. Their rendering is still controlled via the layout files in the mod_menu
layout files/overrides. Layout files are PHP files as usual and the module options are accessible in the code there.
Therefore, you still have all the controls over the rendering while keeping the preset definition as simple and general.
Additionally, I'd like to mention that those default_enable
and default_disabled.php
did not give you much control over rendering rather only on the hierarchy. The HTML output was hard-coded within the class method which could not be overridden. With this PR you get all that flexibility. Your mobile rendering idea too can work even better by just overriding the layout files appropriately and not modifying the preset XML files at all.
Thanks for your reply, Izhar. I will be testing again when time permits on a fresh installation. This week is a little tight though, not sure if it will fit in.
@izharaazmi can you look at the merge conflicts please - then i can test it :)
Sure
@brianteeman I have resolved the conflicts. Travis failure is due to some internal error and not on code.
@brianteeman @andrepereiradasilva It'd be great if we could get this before the 3.8 feature freeze.
Error displaying the error page: Class 'Joomla\CMS\Menu\Tree' not found: Class 'Joomla\CMS\Menu\Tree' not found
@brianteeman Could not reproduce this anywhere. May be I'm missing somewhere. Can you please guide me the steps through it?
Got same Error as @brianteeman wrote.
@brianteeman @franz-wohlkoenig There seems to be some issue with the patch tester applying this patch. Please use the source branch izharaazmi/joomla-cms/menu-preset-features.zip for testing.
I have updated the branch with the latest staging so there should be no conflicts.
I have tested this item
Test:
Created a custom preset (mypreset.xml) in Isis by copying the Modern Preset.
Set a custom menu to use this custom preset.
Set the menu module to also load that preset (both the module and menutype should be set to use the preset).
I deleted in that custom preset all related to User.
Works fine here.
@brianteeman @franz-wohlkoenig Can you try again please! Running out of time for feature freeze.
I have tested this item
Works as described.
Tested custom preset, custom menu, preset import. All good.
Status | Pending | ⇒ | Ready to Commit |
RTC after two successful tests.
Is this too late for 3.8 feature freeze?
Fixing both
Labels |
Added:
?
|
Status | Ready to Commit | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2017-07-31 11:46:17 |
Closed_By | ⇒ | mbabker |
@sanderpotjer It would be really great if you could look at this in the light of our disscussion at #13036 (comment). Thanks.