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

Rerouting on missing route?

Discussion in 'XenForo Development Discussions' started by Jaxel, Feb 26, 2014.

  1. Jaxel

    Jaxel Well-Known Member

  2. Liam W

    Liam W Well-Known Member

    See the source for my vanity names addon, I do something pretty much like this ;)
     
  3. RoldanLT

    RoldanLT Well-Known Member

    I'm using @xfrocks BD Widget Framework to handle my desired content for 404 pages.
     
  4. Jaxel

    Jaxel Well-Known Member

    Thanks, i did it was follows... was very easy:

    Code:
    <?php
    
    class EWRcanal_Listener_Front
    {
        public static function dispatch(XenForo_FrontController $fc, XenForo_RouteMatch &$routeMatch)
        {
            if ($routeMatch->getAction() == 'ErrorNotFound')
            {
                $request = $fc->getRequest()->getRequestUri();
                $splits = explode('/', $request);
               
                if (!empty($splits[1]))
                {
                    $model = XenForo_Model::create('EWRcanal_Model_Channels');
                    $channel = $model->getChannel($splits[1], 'slug');
                   
                    $fc->getRequest()->setRequestUri('/channel'.$request);
                    $routeMatch = $fc->route();
                }
            }
        }
    }
     

Share This Page