Skip to main content
Topic solved
This topic has been marked as solved and requires no further attention.
Topic: Redirect Target for the controller (Read 2868 times) previous topic - next topic

Redirect Target for the controller

It would be nice if the controller would take a parameter that tells it where to redirect after some operation for example adding a record.  For example if you have a contacts / add page and you want the controller to redirect you to accounts/view page after the add then the controller would take a parameter like redirect=accounts/view or something.

Rich

Re: Redirect Target for the controller

Reply #1
@rwebb‍ have you looked at the View Hepler in phprad? You would see that there is a redirect function there, which you can redirect to pages after performing your action.

Re: Redirect Target for the controller

Reply #2
Is there any documentation on this feature? 

Re: Redirect Target for the controller

Reply #3
@rwebb‍ here is the documentation https://phprad.com/info/api#global-function-helper

redirect_to_page($path=null);exit;
Convinient Function To Redirect to Another Page
Example :
Code: [Select]
redirect_to_page("users/view/".USER_ID);exit;

redirect_to_action($action_name=null);exit;
Convinient Function To Redirect to Page Action
Example
Code: [Select]
redirect_to_action('add');exit;

Re: Redirect Target for the controller

Reply #4
This documentation tells how to use the function.  I'm more looking for an example of where I would use that function.   On the add page configuration there is an option for "Redirect to After Add" can I use that function there?  How could I use this function to change where the redirect goes to after say for example adding a record?

 

Re: Redirect Target for the controller

Reply #5
@rwebb‍ the Redirect to After Add uses the above-metioned function. You can select the page you want to redirect to there, but if you want to redirect to a page based on your custom code check, you use the above-stated function, which what you initially asked for. In summary, you can use the code in Page Events.