kongondo / MenuBuilder

Easily create navigation lists/menus using drag and drop
GNU General Public License v2.0
21 stars 9 forks source link

Change the way the extra_fields info is returned from getMenuItems() #45

Open ivangretsky opened 4 years ago

ivangretsky commented 4 years ago

Good day, @kongondo !

I love the new extra_fields option for getMenuItems() on the dev branch!

When used with image fields the returned array for the field is associated and the keys for it are the file names (see the screenshot).

2020-10-26--16-20-44--firefox

I think it would be much easier to deal with numeric keys in the code. For now I have to write something like this:

<img class="main-menu__icon" src="<?= array_shift($p->menu_item_icon)['url'] ?>">

...instead of this:

<img class="main-menu__icon" src="<?= $p->menu_item_icon[0] ?>">

... and get a php notice anyway. The filename of the image is in the array already so seems like there is no need to duplicate it as a key.

What do you think? Or maybe I am using it all wrong?

kongondo commented 4 years ago

Hi @ivangretsky ,

It's been a while since I introduced this feature and I can't quite remember why I did it this way. I could go ahead and change this to use numeric keys but that could potentially break sites that were already using MB dev version.

I'll have a think.

Thanks.

ivangretsky commented 4 years ago

Ok. But that's the great thing about dev branch - you can change things)

P.S. Oh, it's in the master now. But still fresh, so still some time for the breaking changes)))