This topic is locked

Pass variable when menu item is selected

6/17/2022 1:17:00 AM
PHPRunner General questions
A
asawyer13 authorDevClub member

Is it possible to set a session variable or pass a value to the application that's being called from a menu?

When the user clicks on my Report Values page, I want to be able to pass some information to the page so it can be a bit dynamic.

Thanks
Alan

mbintex 6/17/2022

just as ideas:

  • have multiple pages for your report and call these via the menu for several purposes


  • add a ?-parameter to the menu page call and get the parameter with $_GET when landing on the target page with before process event


  • call settings from your user with before process event


  • Set $_SESSION variables for any purpose you want and use these



A
asawyer13 authorDevClub member 6/17/2022

Thanks,
I don't know how I can trap the fact that the user presses a menu item so create any session variables.

First one would work, but a bit messier in that I'd had a lot of report pages, but it would work.

I don't know how the before process would work as I still would need to trap the menu press.

The ? is a possibilty also, so I will think about that one.

The session variable would be perfect but if I can't trap the menu press process I don't think I can do that.

Alan

mbintex 6/17/2022

I don“t know if you can really catch the menu click event, but since all menus call some kind of page, you can kind of catch the menu call by the "before process event" of the target page. If menu "address" is called, the page "address" will tell you as soon as it starts to load.

Sergey Kornilov admin 6/18/2022

Passing the variable via URL is the simplest option here like myreport_report.php?myvar=somevalue

Later you can use any of that report page events to read that value as $_GET["myvar"]