Example #1
0
 public function createUrl($route, $params = array(), $ampersand = '&')
 {
     $route = trim($route, '/');
     //for admin and admin/*
     $parts = explode('/', $route);
     //do not mess with gii
     if ($parts[0] == 'gii') {
         return parent::createUrl($route, $params, $ampersand);
     }
     //        ignore defaultController
     if (Yii::app()->hasModule($parts[0]) && isset($parts[1]) && $parts[1] == Yii::app()->getModule($parts[0])->defaultController) {
         unset($parts[1]);
         $route = implode('/', $parts);
     }
     if (substr(Yii::app()->getRequest()->pathInfo, 0, 6) == 'admin/' || Yii::app()->getRequest()->pathInfo == 'admin') {
         $route = 'admin/' . trim($route, '/');
     }
     $url = parent::createUrl($route, $params, $ampersand);
     if (Settings::get('SEO', 'slugs_enabled')) {
         //handle slugs here
         if ($slug = Slug::getSlug(preg_replace('/' . trim(Yii::app()->baseUrl, '/') . '/', '', $url, 1))) {
             //if (Settings::get('SEO','externalSlug')
             $url = $slug;
             $url = Yii::app()->baseUrl . '/' . $url;
         }
     }
     return $url;
 }