? Success

User tests: Successful: Unsuccessful:

avatar chrBrd
chrBrd
13 Apr 2016

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 and the manifest files docs (where it doesn't state the attribute is for submenu use only).

Summary of Changes

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.

Testing Instructions

  • Download the MVC Component tutorial archive.
  • 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 Comments

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 .

avatar chrBrd chrBrd - open - 13 Apr 2016
avatar chrBrd chrBrd - change - 13 Apr 2016
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 13 Apr 2016
Labels Added: ?
avatar brianteeman
brianteeman - comment - 13 Apr 2016

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

<menu view="cpanel" img="components/com_jce/media/img/menu/logo.png" link="option=com_jce">JCE

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

avatar chrBrd
chrBrd - comment - 13 Apr 2016

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.

avatar mbabker
mbabker - comment - 13 Apr 2016

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 Changes

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.
Testing Instructions

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 Comments

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 .

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

Patch Links:


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#9892

avatar brianteeman
brianteeman - comment - 13 Apr 2016

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

avatar brianteeman brianteeman - change - 13 Apr 2016
Category Libraries
avatar chrBrd
chrBrd - comment - 13 Apr 2016

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().

avatar mbabker
mbabker - comment - 13 Apr 2016

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)

avatar chrBrd
chrBrd - comment - 13 Apr 2016

No worries, I'll copy it over.

avatar chrBrd chrBrd - change - 13 Apr 2016
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2016-04-13 12:40:30
Closed_By chrBrd
avatar chrBrd chrBrd - close - 13 Apr 2016
avatar chrBrd chrBrd - close - 13 Apr 2016
avatar chrBrd chrBrd - change - 13 Apr 2016
Status Closed New
Closed_Date 2016-04-13 12:40:29
Closed_By chrBrd
avatar chrBrd chrBrd - change - 13 Apr 2016
Status New Pending
avatar chrBrd chrBrd - reopen - 13 Apr 2016
avatar chrBrd chrBrd - reopen - 13 Apr 2016
avatar chrBrd
chrBrd - comment - 13 Apr 2016

That's the changes copied over to the component's own adapter.

avatar roland-d
roland-d - comment - 21 Aug 2017

@chrBrd Could you update your PR with the current codebase so we can test this? Thank you.

avatar franz-wohlkoenig franz-wohlkoenig - change - 21 Aug 2017
The description was changed
Status Pending Information Required
avatar joomla-cms-bot joomla-cms-bot - edited - 21 Aug 2017
avatar chrBrd
chrBrd - comment - 21 Aug 2017

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.

avatar roland-d
roland-d - comment - 21 Aug 2017

Thank you for following up, I will get someone else to do this.

avatar roland-d
roland-d - comment - 28 Aug 2017

Closing in favor of #17749

avatar roland-d roland-d - change - 28 Aug 2017
Status Information Required Closed
Closed_Date 0000-00-00 00:00:00 2017-08-28 19:50:30
Closed_By roland-d
avatar roland-d roland-d - close - 28 Aug 2017

Add a Comment

Login with GitHub to post a comment