This topic is locked
[SOLVED]

 Get tab ID

6/17/2020 9:24:36 PM
PHPRunner General questions
rdf author

Hi PHPR community,
Is it possible to get the tab ID of the selected tab on the List page using PHP?
I used another table's index key as the tab ID.
If I can get the tab ID, I want to pass this as the Default Value of the Lookup Wizard.
Thank you

Admin 6/18/2020

When you switch to another tab you can see that URL changes and you can read tab ID from the URL.

rdf author 6/18/2020



When you switch to another tab you can see that URL changes and you can read tab ID from the URL.


Hi Sergey,
Thank you for your reply.
Yeah, I did noticed the tab id parameter on the URL

...URL?tab=tab_id


I tried using $_GET["tab"] but it doesn't seem to return a value at all.
And, can I use it as the Default Value of the Lookup Wizard.

Admin 6/19/2020

$_GET["tab"] is the correct way to access the tab ID. Just remember - tabs are added to the List page meaning that $_GET["tab"] will be available in events on the List page.
Since you are talking about a lookup wizard that means it has something to do with Add or Edit page. Which means you are not explaining the whole picture.
In either case, you can use an event like BeforeProcess of the List page to read $_GET["tab"] and save it in the session variable. Later you can use that session variable anywhere.

$_SESSION["tab"] = $_GET["tab"];
rdf author 6/21/2020



$_GET["tab"] is the correct way to access the tab ID. Just remember - tabs are added to the List page meaning that $_GET["tab"] will be available in events on the List page.
Since you are talking about a lookup wizard that means it has something to do with Add or Edit page. Which means you are not explaining the whole picture.
In either case, you can use an event like BeforeProcess of the List page to read $_GET["tab"] and save it in the session variable. Later you can use that session variable anywhere.

$_SESSION["tab"] = $_GET["tab"];



Hi Sergey,
Thank you for getting back to my question.
Ok, noted on the proper usage by storing the $_GET["tab"] to the $_SESSION["tab"] and then passing it to the Add/Edit page Lookup Wizard Default Value.
I noticed the moment the List page is loaded the URL won't show the tab parameter until its clicked to give $_GET["tab"] the value:

.../formhf_list.php


After clicking the tab it will show the tab parameter on the URL:

.../formhf_list.php?tab=4


You have another way to go around this? I will figure it out as well.
Thank you Sergey for keeping up with all of our questions.

HJB 6/22/2020

https://www.youtube.com/watch?v=x9KqkrOxrKE
... for inspiration purposes only ...

Admin 6/22/2020

If it loads without the tab ID in the URL that the default tab is displayed. You can account for this in your code.

rdf author 6/22/2020



If it loads without the tab ID in the URL that the default tab is displayed. You can account for this in your code.


Hi Sergey,
Any PHPR class I can use to retrieve the tab name instead? I will then query this to get the ID on the table.
Else, I am thinking of JavaScript event function to auto-click after the list page has loaded.
Thank you Sergey.

rdf author 6/22/2020



https://www.youtube.com/watch?v=x9KqkrOxrKE
... for inspiration purposes only ...


Thank you for the link walk2fly...

Admin 6/23/2020

Just give your tabs meaningful names and IDs. I.e. if you specify Germany as both tab title and ID your URL will be orders_list.php?tab=germany

rdf author 6/23/2020



Just give your tabs meaningful names and IDs. I.e. if you specify Germany as both tab title and ID your URL will be orders_list.php?tab=germany


Ok noted Sergey.
Thank you for your suggestion.
I will try this one.

rdf author 6/24/2020

Hi,
Just want to add what I did to resolve my issue:
I just use $_GET on one of my table List page: Before Process using the following code:


//When list page initially load, URL parameter is empty. Assign a value without using $_GET

if ($_GET["tab"] == NULL && $_SESSION["formhf_tab"] == NULL) {

$_SESSION["formhf_tab"] = $tab_id;

}
/*

other code

*/
//If a user click a tab, assign the URL parameter

if ($_GET["tab"] != NULL) {

$_SESSION["formhf_tab"] = $_GET["tab"];

}


And, then add the session variable to the table's Lookup Wizard->Default Value so whichever tab user select that will be the default value to show.



$_SESSION["formhf_tab"];


Thank you PHPR community for the shared ideas.