How to direct to a new page on form submission?

Tristan10

Member
I have followed this tutorial to make a simple add on and adapt it to my own needs.

Basically the user goes to the page and submits a value in a form. After submitting, the page just refreshes as of right now. I would like to direct them to a new page with another form that they can submit. How do I accomplish this? Do I need a new template or page? How do I add another route prefix to handle it (if I need it)? Any help is appreciated.
 
Your current code, based on that review, has this in its controller:
PHP:
//Send a response to the user, so he know that everything went fine with this action
return $this->responseRedirect(
    XenForo_ControllerResponse_Redirect::SUCCESS,
    $this->getDynamicRedirect()
);

It's the getDynamicRedirect() line that redirects you to the same page.

You can specify any link you like here. Use XenForo's link builder:

PHP:
//Send a response to the user, so he know that everything went fine with this action
return $this->responseRedirect(
    XenForo_ControllerResponse_Redirect::SUCCESS,
    XenForo_Link::buildPublicLink('route/action', $linkData, array('query' => 'string'));
);

The second and third parameters there are optional.

Look through exising XenForo code for where "buildPublicLink" is used to get an idea of how it works.
 
Your current code, based on that review, has this in its controller:
PHP:
//Send a response to the user, so he know that everything went fine with this action
return $this->responseRedirect(
    XenForo_ControllerResponse_Redirect::SUCCESS,
    $this->getDynamicRedirect()
);

It's the getDynamicRedirect() line that redirects you to the same page.

You can specify any link you like here. Use XenForo's link builder:

PHP:
//Send a response to the user, so he know that everything went fine with this action
return $this->responseRedirect(
    XenForo_ControllerResponse_Redirect::SUCCESS,
    XenForo_Link::buildPublicLink('route/action', $linkData, array('query' => 'string'));
);

The second and third parameters there are optional.

Look through exising XenForo code for where "buildPublicLink" is used to get an idea of how it works.

I don't really understand. Sorry, I am REALLY new at this. I have created another page that I want to redirect them to. But I don't know how to use buildPublicLink or Routes/Prefixes. Let alone together. Could you elaborate a little more? Or tell me where I can find information regarding these things? Thanks.
 
One way to build that link is like this:
PHP:
//Send a response to the user, so he know that everything went fine with this action
return $this->responseRedirect(
    XenForo_ControllerResponse_Redirect::SUCCESS,
    XenForo_Link::buildPublicLink('pages', array('node_name' => 'XboxVerificationConfirm'));
);
 
Back
Top Bottom