Reply
Highlighted
Emerging Member
Posts: 118
Registered: ‎01-19-2015
Kudos: 90
Solutions: 1
Accepted Solution

How to many Menu Items with only one plug-in?

Hi, with new V2.14 menu option we can use the menu option.

Until now when I use a menu item with iframe I get executed the public.php of the plug-in.

 

I saw in the manifest doc that we can add parameters like hooks.

Is there a way to select between one function or other of the plug-in with this hook? Any php example to follow?

 

Thanks in advance


Accepted Solutions
Member
Posts: 196
Registered: ‎03-19-2018
Kudos: 31
Solutions: 7

Re: How to many Menu Items with only one plug-in?

The menu items are defined as key value query params.

 

If your menu looks like this:

 

"menu": [
    {
        "key": "Reports",
        "label": "Dummy main menu item",
        "type": "admin",
        "target": "iframe",
        "parameters": {
            "admin": "main"
        }
    },
    {
        "key": "Reports",
        "label": "Dummy second menu item",
        "type": "admin",
        "target": "iframe",
        "parameters": {
            "admin": "secondary"
        }
    }
]

You can setup conditions like this:

 

if ($_GET['admin'] == 'main') {
  // code to run if main menu item is selected
}

if ($_GET['admin'] == 'secondary') {
  // code to run if secondary menu item is selected
}

 

HTML, SCSS, Javascript(Ember.js), Ruby(Ruby on Rails), PHP

View solution in original post


All Replies
Member
Posts: 196
Registered: ‎03-19-2018
Kudos: 31
Solutions: 7

Re: How to many Menu Items with only one plug-in?

The menu items are defined as key value query params.

 

If your menu looks like this:

 

"menu": [
    {
        "key": "Reports",
        "label": "Dummy main menu item",
        "type": "admin",
        "target": "iframe",
        "parameters": {
            "admin": "main"
        }
    },
    {
        "key": "Reports",
        "label": "Dummy second menu item",
        "type": "admin",
        "target": "iframe",
        "parameters": {
            "admin": "secondary"
        }
    }
]

You can setup conditions like this:

 

if ($_GET['admin'] == 'main') {
  // code to run if main menu item is selected
}

if ($_GET['admin'] == 'secondary') {
  // code to run if secondary menu item is selected
}

 

HTML, SCSS, Javascript(Ember.js), Ruby(Ruby on Rails), PHP
Emerging Member
Posts: 118
Registered: ‎01-19-2015
Kudos: 90
Solutions: 1

Re: How to many Menu Items with only one plug-in?

Oh! it was so easy, and i didn't know it =/

Thanks for your time.
Kind regards
Reply