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

Help with responseReroute()

Discussion in 'XenForo Development Discussions' started by Dannymh, Feb 17, 2015.

  1. Dannymh

    Dannymh Active Member


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

    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?
  2. Mr. Goodie2Shoes

    Mr. Goodie2Shoes Well-Known Member

    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:
  3. Dannymh

    Dannymh Active Member

    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
  4. Dannymh

    Dannymh Active Member

    Ok further research reveals setParam is the way to go


  5. Mr. Goodie2Shoes

    Mr. Goodie2Shoes Well-Known Member

    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:
    $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:
    $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
    Dannymh likes this.
  6. Mr. Goodie2Shoes

    Mr. Goodie2Shoes Well-Known Member

    ninja'd :p
    Dannymh likes this.
  7. Dannymh

    Dannymh Active Member

    Thanks for your help mate, appreciate it.
    Mr. Goodie2Shoes likes this.

Share This Page