User tests: Successful: Unsuccessful:
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.
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:
com_sample
uses com_categories
for two category types: main
and foo
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.
Categories > List All Categories
and make sure that in the Choose a Component dropdown the Articles
, Banners
, Contact
, Newsfeeds
and Users
are listed.Fields > List All Fields
and make sure that in the Choose a Component dropdown the Articles
, Contact
, and Users
are listed.com_sample
and see if the above lists are updated to include a new entry Sample
as well.Add this in manifest documentation.
Pinging @infograf768 @rdeutz
Status | New | ⇒ | Pending |
Category | ⇒ | Administration com_banners com_categories com_contact com_content com_fields com_menus com_newsfeeds com_users Language & Strings |
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.
Title |
|
Title |
|
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2018-08-18 12:59:34 |
Closed_By | ⇒ | brianteeman |
In J4 an extension does define the features it uses through interfaces anyway.
1.-3: Tested Categories (all 5 are shown) and Fields (all 3 shown) on
Articles
, both Menus works.4.: New Entry are
Sample Categories
andSample 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