? ? Failure

User tests: Successful: Unsuccessful:

avatar izharaazmi
izharaazmi
4 Feb 2017

Summary of Changes

We have some components in Joomla such as com_categories which are used across other extension. Another such extension recently added is com_fields. I call these as feature extensions, as they add features to other extensions with seamless integration.

Now that said, many other core as well as 3PD extensions makes use of them. Currently we do not have a way to tell whether a given component say com_sample uses these feature components or not. Similar issue was observed when creating a list of components which uses com_categories and we have no straight way to look at. Thankfully, @infograf768 came up with a best possible workaround there.

Here I am suggesting a straight path that can be used henceforth to identify all existing or possibly upcoming feature extension usage in other extensions. This is not just useful to create a menu link, rather when this information is made available on can think of various other uses.

Prototype

Let us assume we have a component com_sample that uses com_categories and com_fields both. Currently as Joomla core or any other extension than com_sample itself, we do not have a clear way to know that.

I propose to update the install manifests structure for components as below.

Current format

<extension type="component" version="3.0" method="upgrade">
	<name>COM_SAMPLE</name>
	...
	<files folder="site">
		...
	</files>
	<administration>
		...
	</administration>
	...
</extension>

Proposed Addition

<extension type="component" version="3.0" method="upgrade">
	<name>COM_SAMPLE</name>
	...
	<files folder="site">
		...
	</files>
	<administration>
		...
	</administration>
	<features>
		<feature type="com_categories" name="com_sample" label="COM_SAMPLE_CATEGORIES_MAIN"/>
		<feature type="com_categories" name="com_sample.foo" label="COM_SAMPLE_CATEGORIES_FOO"/>
		<feature type="com_fields" name="com_sample" label="COM_SAMPLE_FIELDS_MAIN"/>
		<feature type="com_fields" name="com_sample.bar" label="COM_SAMPLE_FIELDS_BAR"/>
	</features>
	...
</extension>

This way we can now tell just by reading the component manifest that:

  1. com_sample uses com_categories for two category types: main and foo
  2. com_sample uses com_fields for two field types: main and bar

The format is:

<features>
	<feature type="FEATURE_COMPONENT_NAME" label="DISPLAY_NAME">
		<!-- Optionally, any other feature specific parameters, 
		which can be defined and documented by the feature component -->
	</feature>
</features>

I have updated the core components manifests with this structure.

Test Instruction

  1. Create a custom admin menu and add a new menu item
  2. Choose menu item type Categories > List All Categories and make sure that in the Choose a Component dropdown the Articles, Banners, Contact, Newsfeeds and Users are listed.
  3. Choose menu item type Fields > List All Fields and make sure that in the Choose a Component dropdown the Articles, Contact, and Users are listed.
  4. Install the attached com_sample and see if the above lists are updated to include a new entry Sample as well.
  5. Make sure all those links created this way, works.

Documentation Changes Required

Add this in manifest documentation.

com_sample.zip

Pinging @infograf768 @rdeutz

avatar izharaazmi izharaazmi - open - 4 Feb 2017
avatar izharaazmi izharaazmi - change - 4 Feb 2017
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 4 Feb 2017
Category Administration com_banners com_categories com_contact com_content com_fields com_menus com_newsfeeds com_users Language & Strings
avatar izharaazmi izharaazmi - change - 4 Feb 2017
The description was changed
avatar izharaazmi izharaazmi - edited - 4 Feb 2017
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 4 Feb 2017

1.-3: Tested Categories (all 5 are shown) and Fields (all 3 shown) on Articles, both Menus works.
4.: New Entry are Sample Categories and Sample Foo Categories / Sample Bar Fields, Sample Fields

Test on:

Joomla! 3.7.0-beta1
macOS Sierra, 10.12.3
Firefox 50.1.0
PHP 7.0.4
MySQLi 5.5.53-0

avatar Bakual
Bakual - comment - 4 Feb 2017

For com_fields, we already have a way to get the available contexts.
The respective formfield (used eg in com_contact) is https://github.com/joomla/joomla-cms/blob/staging/administrator/components/com_fields/models/fields/fieldcontexts.php
It makes use of an optional helper method "getContexts" in the extension (https://github.com/joomla/joomla-cms/blob/staging/administrator/components/com_contact/helpers/contact.php#L206-L224).
There is also another helper method "validateSection" (https://github.com/joomla/joomla-cms/blob/staging/administrator/components/com_contact/helpers/contact.php#L179-L204) which can be used to detect if an extension (or more precise a context) supports fields.

Manually loading and parsing the manifest xml file doesn't look right to me. If we want to go this way, the contents must be stored in the database (€__extensions -> "manifest_cache") and loaded from there. But it means iterating over the extension, json_decode the string and check if the feature is supported.

I think there is also an API to fetch the enabled components (JComponentHelper::something()) and I think it allows also to fetch the manifest cache.

avatar joomla-cms-bot joomla-cms-bot - change - 7 Apr 2017
Title
Feature components in component manifest
[com_fields] Feature components in component manifest
avatar franz-wohlkoenig franz-wohlkoenig - change - 7 Apr 2017
Title
Feature components in component manifest
[com_fields] Feature components in component manifest
avatar joomla-cms-bot joomla-cms-bot - edited - 7 Apr 2017
avatar brianteeman
brianteeman - comment - 18 Aug 2018

Thanks for this PR but I am closing ti for the reasons stated by @Bakual above

avatar brianteeman brianteeman - change - 18 Aug 2018
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2018-08-18 12:59:34
Closed_By brianteeman
avatar brianteeman brianteeman - close - 18 Aug 2018
avatar laoneo
laoneo - comment - 18 Aug 2018

In J4 an extension does define the features it uses through interfaces anyway.

Add a Comment

Login with GitHub to post a comment