Create a new admin menu type.
For that menutype, create a new menu item of type "Component Configuration".
In the "Choose a component" dropdown, one can choose "Administrator - System Information"
But, as System Information has no Configuration, therefore we have an error clicking on the link.
"index.php?option=com_config&view=component&component=com_admin"
`Fatal error: Call to a member function getFieldsets() on a non-object in ROOT/administrator/components/com_config/view/component/html.php on line 57
Same issue for "Ajax Interface", "Mailto", etc.
I guess we should check for a config.xml to filter the list.
Labels |
Added:
?
|
We could patch this way
<?php
/**
* @package Joomla.Platform
* @subpackage Form
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
use Joomla\Utilities\ArrayHelper;
JFormHelper::loadFieldClass('list');
/**
* Form Field class for the Joomla Framework.
*
* @since 3.7.0
*/
class JFormFieldComponents extends JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 3.7.0
*/
protected $type = 'Components';
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*
* @since 11.4
*/
protected function getOptions()
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('name AS text, element AS value')
->from('#__extensions')
->where('enabled >= 1')
->where('client_id = 1')
->where('type =' . $db->quote('component'));
$items = $db->setQuery($query)->loadObjectList();
if ($items)
{
foreach ($items as $i => $item)
{
$extension = $item->value;
if (!JFile::exists(JPATH_ADMINISTRATOR . '/components/' . $extension . '/config.xml'))
{
unset($items[$i]);
}
else
{
// Load language
$lang = JFactory::getLanguage();
$lang->load("$extension.sys", JPATH_ADMINISTRATOR, null, false, true)
|| $lang->load("$extension.sys", JPATH_ADMINISTRATOR . '/components/' . $extension, null, false, true);
// Translate component name
$item->text = JText::_($item->text);
}
}
// Sort by component name
$items = ArrayHelper::sortObjects($items, 'text', 1, true, true);
}
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), $items);
return $options;
}
}
But I also suggest to move this new field (was created in 3.7.0 specially for custom adminmenus (4e156fa#diff-04143b9041f6e1141a3bf55bc54df432)
to com_menus/models/fields/
as it is really specific to admin menus
@izharaazmi You do or I do?
I'll look at this tomorrow, or maybe today if I could make it to my desk.
However, your suggested patch makes it specific to the purpose on
com_menus. I intended to make it general that's why I put it that way.
Additionally, I'd anyway like to also add the "instanceOf SimpleXmlElement"
check where it throws the fatal error. Then we can decide whether we need
to change this field or not.
It can't be a general field type if we need to check the config.xml.
I would also suggest to change it to
protected $type = 'Componentsconfig';
in order to not confuse it with the user one( filter_debugggroup and filter_debuguser).
and maybe, place it in com_config new /fields/ folder instaed of com_menus.
@infograf768 Please see #14267
Title |
|
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2017-02-28 07:18:25 |
Closed_By | ⇒ | infograf768 |
Title |
|
Closing as we have a patch
I can confirm