Skip to content

Commit 50ecbba

Browse files
authored
[4.0] Easier add links to com_fields (#34824)
* Easier add links to com_fields * Different approach
1 parent 82bbbc8 commit 50ecbba

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

administrator/modules/mod_menu/src/Menu/CssMenu.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,19 @@ protected function preprocess($parent)
310310
}
311311
}
312312

313+
$uri = new Uri($item->link);
314+
$query = $uri->getQuery(true);
315+
316+
/**
317+
* If component is passed in the link via option variable, we set $item->element to this value for further
318+
* processing. It is needed for links from menu items of third party extensions link to Joomla! core
319+
* components like com_categories, com_fields...
320+
*/
321+
if ($option = $uri->getVar('option'))
322+
{
323+
$item->element = $option;
324+
}
325+
313326
// Exclude item if is not enabled
314327
if ($item->element && !ComponentHelper::isEnabled($item->element))
315328
{
@@ -340,13 +353,10 @@ protected function preprocess($parent)
340353

341354
if ($item->element === 'com_categories')
342355
{
343-
parse_str($item->link, $query);
344356
$assetName = $query['extension'] ?? 'com_content';
345357
}
346358
elseif ($item->element === 'com_fields')
347359
{
348-
parse_str($item->link, $query);
349-
350360
// Only display Fields menus when enabled in the component
351361
$createFields = null;
352362

@@ -381,8 +391,6 @@ protected function preprocess($parent)
381391
}
382392
elseif ($item->element === 'com_workflow')
383393
{
384-
parse_str($item->link, $query);
385-
386394
// Only display Workflow menus when enabled in the component
387395
$workflow = null;
388396

@@ -419,8 +427,6 @@ protected function preprocess($parent)
419427
}
420428
elseif ($item->element === 'com_admin')
421429
{
422-
parse_str($item->link, $query);
423-
424430
if (isset($query['view']) && $query['view'] === 'sysinfo' && !$user->authorise('core.admin'))
425431
{
426432
$parent->removeChild($item);

0 commit comments

Comments
 (0)