Redirect Edit page Conditional for record

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
toothspoon
User
Posts: 13

Redirect Edit page Conditional for record

Post by toothspoon »

Hi,

I am trying to redirect the edit page for records that exist in different tables, based on a conditional.

If conditional 1 is met then the edit page for that record is opened in page1.php
If conditional 2 is met then the edit page for the record, (matching to id/fk), is opened in page2.php

I can do the redirect if the edit button is clicked, but I need the redirected page to open the edit page for the desired record.

Any ideas would be much appreciated.


mobhar
User
Posts: 11745

Post by mobhar »

toothspoon wrote:
but I need the redirected page to open the edit page for the desired record.

After which event did you want to use that redirecting?


toothspoon
User
Posts: 13

Post by toothspoon »

On the list page.
I click the edit button for a record.

Depending on the conditional either
the edit page for the record will open (From the first list page), or
the 2nd edit page, matching on a table value / fk will open.

Table 1 - ' allpeople ' : (Default page)
id auto name
1 0 john
2 1 jo
3 1 kim

Table 2 = ' teachers ':
id auto name address
1 0 john abalone
2 1 jeremy nowhere
3 1 kim everywhere

The id's in the 2 tables are not the same, the join needs to be on the name.

From the default page, if I click on edit for ' jo ', it will just open that record on that page ready for editing.
If I click on edit for john then it will open the record for john on table 2 ready for editing.

The Edit Page / Page_Redirecting event:

// Page Redirecting event
function Page_Redirecting(&$url) {

if ($this->auto->CurrentValue == 0) {
$url = "table2.php"; }

}


mobhar
User
Posts: 11745

Post by mobhar »

For such case, then you need to use "ListOptions_Load" and "ListOptions_Rendered" server event in order to add a new column/button for each record, and then make the link for that button to open the Edit page of "teachers" table.

Please read "Server Events and Client Scripts" topic from PHPMaker Help menu for more info and example.


Post Reply