Skip to content

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

@ivangretsky

Description

@ivangretsky

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions