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

Rerouting on missing route?

Jaxel

Well-known member
#1

Jaxel

Well-known member
#4
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();
            }
        }
    }
}