Quick PHP 8 fix for MenuManager please!

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
User avatar
Charles Butcher
Forum Members
Forum Members
Posts: 102
Joined: Sat Jul 05, 2008 8:25 pm
Location: Norfolk, UK

Quick PHP 8 fix for MenuManager please!

Post by Charles Butcher »

I would be very grateful if someone could tell me how to patch the MenuManager module to work with PHP 8. The "each" at line 111:

Code: Select all

while (list($key) = each($children)) {
breaks the site. I tried:

Code: Select all

foreach( $children as $key ) {
without success. I know I should probably be using Navigator instead, but I'm not a developer and until I can get my head round that I'd like to keep it working with MenuManager and PHP 8 if possible.

Any hints appreciated.
MantaPro
Forum Members
Forum Members
Posts: 97
Joined: Sun Feb 03, 2008 8:14 pm

Re: Quick PHP 8 fix for MenuManager please!

Post by MantaPro »

Try

Code: Select all

 foreach ($children as $key => $value)
In the old code the each returns the key & value pairs. The list assigns the key but ignores the value.

In your attempted code you were looping through the children and assigning the value to a field called key. Whereas you want the field called key to hold the key.

Good luck
User avatar
Charles Butcher
Forum Members
Forum Members
Posts: 102
Joined: Sat Jul 05, 2008 8:25 pm
Location: Norfolk, UK

Re: Quick PHP 8 fix for MenuManager please!

Post by Charles Butcher »

Thank you very much indeed! That works. Now the errors have moved to old modules like CGGoogleMaps – but it's progress :-)
User avatar
DIGI3
Dev Team Member
Dev Team Member
Posts: 1627
Joined: Wed Feb 25, 2009 4:25 am
Location: Victoria, BC

Re: Quick PHP 8 fix for MenuManager please!

Post by DIGI3 »

Just a reminder that source code changes are not permitted on the forum (there's pinned posts outlining the reasoning so I won't get into it here). Also keep in mind MenuManager was deprecated years ago, and will stop being included very soon. Migrating to Navigator is the best option.
Not getting the answer you need? CMSMS support options
User avatar
Charles Butcher
Forum Members
Forum Members
Posts: 102
Joined: Sat Jul 05, 2008 8:25 pm
Location: Norfolk, UK

Re: Quick PHP 8 fix for MenuManager please!

Post by Charles Butcher »

Thanks DIGI3, and apologies for breaking that rule – which makes perfect sense. I'll get to grips with Navigator. I inherited the original MenuManager template in 2009 as part of a complete site design, so I have never needed to understand it. This will be a useful learning experience.
Post Reply

Return to “Modules/Add-Ons”