Undefined array key Topic is solved

For Joomla! 4.x Coding related discussions, please use: http://groups.google.com/group/joomla-dev-general

Moderator: ooffick

Forum rules
Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum.
Post Reply
ant3000
Joomla! Apprentice
Joomla! Apprentice
Posts: 31
Joined: Fri Oct 02, 2009 12:44 pm

Undefined array key

Post by ant3000 » Mon Jun 20, 2022 1:50 pm

I'm working on upgrading a site from J3 to J4 and using the GiMeSpace Bootstrapped Menu module.

Everything appeared to be working fine until I upgraded the PHP to 8 and I'm now getting the following notification with Error Reporting set to - "System Default"

Warning: Undefined array key "class" in /Applications/.../modules/mod_gmsmenu4/tmpl/default_component.php on line 25

I did reach out to the GiMeSpace developer but haven't had a response and I'm guessing this might be resolved with a code tweak but while I can just about understand the principle of what might be happening by reading the PHP code I'm a bit clueless as to how to write it and wondered if there was anybody who could help?

The code is -

Code: Select all


use Joomla\CMS\Filter\OutputFilter;
use Joomla\CMS\HTML\HTMLHelper;

$attributes = array();

if ($item->level>1)
{
	$attributes['class'] .= 'dropdown-item ';
}
else
{
	$attributes['class'] .= 'nav-link ';
}

I realise I could just set error reporting to "None" but it would be great if I can find a proper solution

Many thanks in advance

User avatar
drmenzelit
Joomla! Intern
Joomla! Intern
Posts: 85
Joined: Sat Oct 22, 2011 8:30 am
Contact:

Re: Undefined array key

Post by drmenzelit » Tue Jun 28, 2022 2:54 pm

You should not report errors on the frontend on a live site by the way... and it is "only" a warning not an error. You can check the standard menu module and try to find out where the differences in the code are.

MarkRS
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 109
Joined: Thu Oct 29, 2009 8:28 am
Location: UK

Re: Undefined array key

Post by MarkRS » Tue Jun 28, 2022 4:20 pm

Also, it would be good to at least post this as "solved", since you got an answer in the mailing list. 8)
It's a community, the more we all contribute, the better it will be.

ant3000
Joomla! Apprentice
Joomla! Apprentice
Posts: 31
Joined: Fri Oct 02, 2009 12:44 pm

Re: Undefined array key

Post by ant3000 » Tue Jun 28, 2022 5:16 pm

MarkRS wrote:
Tue Jun 28, 2022 4:20 pm
Also, it would be good to at least post this as "solved", since you got an answer in the mailing list. 8)
Will do - thanks


Post Reply

Return to “Joomla! 4.x Coding”