User tests: Successful: Unsuccessful:
The link attribute in the parent administrator
element of a component XML manifest is currently completely ignored on installation; it isn't used anywhere. Instead the link is built using a value derived from the undocumented, therefore typically not present, element. As there is usually not a value set for this it defaults to using the component's , causing issues if you want to have the component named slightly differently from any desired URLs.I'm assuming the link attribute should do something on parent menus, as it's included in all the core component manifests, as well as the 3.x MVC Component tutorial and the manifest files docs (where it doesn't state the attribute is for submenu use only).
Created a new method, getMenuLinkOption(), in JInstallerAdapter. This is executed in the getElement() method in the same class. If the admin menu element's link attribute is set it returns a filtered string matching all text after 'option='.
If a string is returned it becomes the extension's element attribute, otherwise the element value defaults to the element from the manifest as usual.
The link to the component in the administrator menu will still work, but the component's name in the extension manager will be 'Simple Hello World Component'. Submenus are linked properly too.
I originally started out changing _buildAdminMenus in JInstallerAdapterComponent. The $option variable used to build all the admin menu links is the value of the manifest's element. This isn't set in any XML manifest I've found and the only reference to it in the code is in the JUpdate class where it doesn't seem to do anything. Rather than modifying _buildAdminMenus, it was far neater to create a new method in JInstallerAdapter and set the element to the menu link's option. Setting the element attribute this way seems to make more sense given what it's used for anyway.
The new method maintains compatibility should anyone have used in a manifest. It will also function as normal and default to the element's value if a menu link is not set. If the link attribute's option is changed without a clean install of the component you'll get the same errors you would by changing the component's .
Status | New | ⇒ | Pending |
Labels |
Added:
?
|
Look for these lines in the XML:
<administration>
<menu view="cpanel" img="components/com_jce/media/img/menu/logo.png" link="option=com_jce">JCE</menu>
Currently link="option=com_jce"
is completely redundant, it isn't used anywhere. Instead admin menu links are built using:
$data['link'] = 'index.php?option=' . $option;
in the _buildAdminMenus() method in JInstallerAdapterComponent. That value, $option, is initialised like this at the start of the method:
$option = $this->get('element');
This then executes the getElement() method from JInstallerAdapter (which is what I've changed).
Here's the original code:
if (!$element)
{
// Ensure the element is a string
$element = (string) $this->getManifest()->element;
}
if (!$element)
{
$element = $this->getName();
}
In any manifest without <element> tags, which is probably all of them, this line always returns null:
$element = (string) $this->getManifest()->element;
Consequently $element always defaults to the value of <name>, and in turn the value of $data['link'] = 'index.php?option=' . $option;
will always be the same as $data['link'] = 'index.php?option=jce
, regardless of how the link option is set in the manifest.
If, for any reason, you decided to set link="option=com_jceditor"
, for example, it wouldn't work - that link attribute is completely pointless at the moment.
If accepted this change needs to be made in the component adapter, not the
base adapter class in a method that will be run on all adapters.
On Wednesday, April 13, 2016, Chris Bradbury notifications@github.com
wrote:
Issue
The link attribute in the parent administrator
element of a
component XML manifest is currently completely ignored on installation; it
isn't used anywhere. Instead the link is built using a value derived from
the undocumented, therefore typically not present, element. As
there is usually not a value set for this it defaults to using the
component's , causing issues if you want to have the component named
slightly differently from any desired URLs.I'm assuming the link attribute should do something on parent menus, as
it's included in all the core component manifests, as well as the 3.x MVC
Component tutorial
https://docs.joomla.org/J3.x:Developing_an_MVC_Component/Adding_a_menu_type_to_the_site_part
and the manifest files docs
https://docs.joomla.org/Manifest_files#Menu_links_and_submenus (where
it doesn't state the attribute is for submenu use only).
Summary of ChangesCreated a new method, getMenuLinkOption(), in JInstallerAdapter. This is
executed in the getElement() method in the same class. If the admin menu
element's link attribute is set it returns a filtered string matching all
text after 'option='.If a string is returned it becomes the extension's element attribute,
otherwise the element value defaults to the element from the
manifest as usual.
Testing Instructions
- Download the MVC Component tutorial archive https://github.com/scionescire/Joomla-3.2-Hello-World-Component/archive/step-3-adding-a-site-menu.zip .
- In the component's XML manifest file change value of the element to 'Simple Hello World Component'.
- Install the component
The link to the component in the administrator menu will still work, but
the component's name in the extension manager will be 'Simple Hello World
Component'. Submenus are linked properly too.
Additional CommentsI originally started out changing _buildAdminMenus in
JInstallerAdapterComponent. The $option variable used to build all the
admin menu links is the value of the manifest's element. This
isn't set in any XML manifest I've found and the only reference to it in
the code is in the JUpdate class where it doesn't seem to do anything.
Rather than modifying _buildAdminMenus, it was far neater to create a new
method in JInstallerAdapter and set the element to the menu link's option.
Setting the element attribute this way seems to make more sense given what
it's used for anyway.The new method maintains compatibility should anyone have used
in a manifest. It will also function as normal and default to the
element's value if a menu link is not set. If the link attribute's option
is changed without a clean install of the component you'll get the sameerrors you would by changing the component's .
You can view, comment on, or merge this pull request online at:
#9892
Commit Summary
- Initialised
- Deployment set
- component.php reset
- Adapter changes made
File Changes
- M libraries/cms/installer/adapter.php https://github.com/joomla/joomla-cms/pull/9892/files#diff-0 (44)
Patch Links:
- https://github.com/joomla/joomla-cms/pull/9892.patch
- https://github.com/joomla/joomla-cms/pull/9892.diff
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#9892
If, for any reason, you decided to set link="option=com_jceditor", for example, it wouldn't work - that link attribute is completely pointless at the moment.
OK I can confirm that part - thanks for the explanation
Category | ⇒ | Libraries |
I thought that may well be the case.
In that case, however, the getElement() method in JInstallerAdapter is totally redundant. I can't find any examples of any Joomla manifests including <element> tags, so all it's doing is seeking a null value and then running getName().
It may well be something that extension developers aren't implementing for
whatever reason (redundant value or undocumented feature). Either way the
menu item processing is specific to components and shouldn't be in code
executed in all adapters.
On Wednesday, April 13, 2016, Chris Bradbury notifications@github.com
wrote:
I thought that may well be the case.
In that case, however, the getElement() method in JInstallerAdapter is
totally redundant. I can't find any examples of any Joomla manifests
including tags, so all it's doing is seeking a null value and
then running getName().—
You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#9892 (comment)
No worries, I'll copy it over.
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2016-04-13 12:40:30 |
Closed_By | ⇒ | chrBrd |
Status | Closed | ⇒ | New |
Closed_Date | 2016-04-13 12:40:29 | ⇒ | |
Closed_By | chrBrd | ⇒ |
Status | New | ⇒ | Pending |
That's the changes copied over to the component's own adapter.
Status | Pending | ⇒ | Information Required |
I'm afraid that probably won't be happening any time soon - I'm currently busy as sin with other stuff and don't have a working Joomla dev environment ready to go at the moment.
Thank you for following up, I will get someone else to do this.
Status | Information Required | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2017-08-28 19:50:30 |
Closed_By | ⇒ | roland-d |
I m a little confused by your initial comments so I went to look at the first component I could find which was JCE
This has a line in the xml
Which if I understand you correctly you are saying is completely ignored by Joomla during installation and the link is generated by some <element>
As there is no <element> in JCE I wondered where the menu is coming from if as you say the <menu> element is ignored. So to test I deleted that line from the xml and installed JCE. Guess what - no admin menu. My only conclusion is that the <menu> element is working as documented - or am i missing something