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

Route Params Correction

Discussion in 'XenForo Development Discussions' started by Jeremy P, Nov 4, 2010.

  1. Jeremy P

    Jeremy P Well-Known Member

    I have a modification where the username and id are parameters in the route, ie:

    Using resolveActionWithIntegerParam(), I am able to get the user_id in the controller fine. However, in the event the username does not match the id, I'd like to redirect to the matching username, much like user profiles do by default. I'm not sure how to go about it.. any ideas?


    Edit - Another question:
    I have an action that accepts post data from a form in another action. It ends with a redirect response:
    return $this->responseRedirect(XenForo_ControllerResponse_Redirect::RESOURCE_CREATED,
    XenForo_Link::buildPublicLink('hello-world'$visitor), new XenForo_Phrase('helloWorld_the_data_has_been_added_successfully'));
    When the form is posted, the success message is flashed at the top of the screen, but no redirect occurs. How would I invoke the redirect after the success message, like how it is done if you go to the advanced post page?
  2. Arik

    Arik Well-Known Member

    For your first question, check out XenForo_Controller::canonicalizeRequestUrl(). Should do what you're looking for.
    Vladislav Rastrusny likes this.
  3. Jeremy P

    Jeremy P Well-Known Member

    That did the trick, thanks. :)

    Anyone have an idea for the 2nd question?
  4. Jeremy P

    Jeremy P Well-Known Member

    Figured it out - needed to add 'data-redirect="on"' to my <form> tag :)

Share This Page