• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Help with responseReroute()

Dannymh

Active member
#1
Hi,

I am trying to pass paramaters to responseReroute with the following code

PHP:
return $this->responseReroute(__CLASS__, 'Manageplayers', array("id" => 2, "title" => 'list'));
Looking in eclipse at the documentation for this it says that the last section should be able to handle key/value pairs as parameters.

However it looks like these are being ignored. I want to basically display the same thing that would show if the user went to the URL yoursite/mvp/list.2/

Is there another or better way to do this?
 

Mr. Goodie2Shoes

Well-known member
#2
responseReroute is used to tell XF's FrontController to 'reroute' the request to the specified controller and action, in this case the specified class and the method 'actionManageplayers'.

What exactly are you trying to achieve? As I am quite confused with:
I want to basically display the same thing that would show if the user went to the URL yoursite/mvp/list.2/
 

Dannymh

Active member
#3
It is after a save action, instead of redirecting to a page, I just want it to load the results, which would ordinarily be pulled up by ManagePlayers

If works by checking the title (list) sees that it is list, and the id is 2 (params passed through URL). It then uses the ID to grab the data.

The issue here is that it is not getting the List param.

I.e. if you go to Yoursite.com/mvp/list.2/manageplayers

the addon goes to the controller for mvp and looks for the action manageplayers. Inside the manage players action I parse the two parameters which are id and title in this case.

if the title is list then it displays a list.

Now after a save action in this addon, I want to redirect back to that URL, but preferebly just do the response view with those params
 

Dannymh

Active member
#4
Ok further research reveals setParam is the way to go

PHP:
$this->_request->setParam('id', 2);

$this->_request->setParam('title', 'list');
 

Mr. Goodie2Shoes

Well-known member
#5
I would suggest to go with AJAX for this. But if you want to go with showing the result page inside the save action you'll have to add the id to the request, something like this:
PHP:
$this->_request->setParam('id', $id);
$this->_request->setParam('title', $title);
return $this->responseReroute(__CLASS__, 'ManagePlayers'); // As I am guessing the method name is actionManagePlayers()
and the id and title will be available inside the actionManagePlayers by calling:
PHP:
$id = $this->_input->filterSingle('id', XenForo_Input::UINT);
$title = $this->_input->filterSingle('title', XenForo_Input::STRING);
P.S. I just wrote these here so keep an eye for any typo :p