Rerouting on missing route?

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();
            }
        }
    }
}
 
Back
Top Bottom