 
      
    Yii
- 12 ответов
- 0 вопросов
    5
    Вклад в тег
    
      
      
    
  
  
/domain/public_html/yii hello/indexphp /domain/public_html/yii hello/index/domain/public_html/yii hello/index<?php
namespace app\components;
use yii\web\UrlRuleInterface;
use yii\base\Object;
class JoomlaUrlRule extends Object implements UrlRuleInterface
{
    public function createUrl($manager, $route, $params)
    {
        return false;
    }
    public function parseRequest($manager, $request)
    {
        $it_joomla_url = $request->getPathInfo()==='' 
                     && $request->getQueryParam('option')==='com_content';
        if (!it_joomla_url) {
            return false;            
        }
        $view = $request->getQueryParam('view');
        if (empty($view)) {
            return false;            
        }
        return ["$view/view", $request->queryParams];
    }
}[
    'components' => [
        'urlManager' => [
            // ...
            'rules' => [
                ['class' => 'app\components\JoomlaUrlRule'],
                // ...
            ],
        ],
    ],
]RewriteCond %{THE_REQUEST} index.php [NC]
RewriteCond %{QUERY_STRING} option=com_content [NC]
RewriteCond %{QUERY_STRING} view=category [NC]
RewriteRule (.*) /category/view/ [L,R=301,QSA]
RewriteCond %{THE_REQUEST} index.php [NC]
RewriteCond %{QUERY_STRING} option=com_content [NC]
RewriteCond %{QUERY_STRING} view=article [NC]
RewriteRule (.*) /article/view/ [L,R=301,QSA]RewriteCond %{THE_REQUEST} index.php [NC]
RewriteCond %{QUERY_STRING} option=com_content [NC]
RewriteCond %{QUERY_STRING} view=category [NC]
RewriteCond %{QUERY_STRING} id=(\d+) [NC]
RewriteRule (.*) /category/view?id=%1 [L,R=301]
RewriteCond %{THE_REQUEST} index.php [NC]
RewriteCond %{QUERY_STRING} option=com_content [NC]
RewriteCond %{QUERY_STRING} view=article [NC]
RewriteCond %{QUERY_STRING} id=(\d+) [NC]
RewriteRule (.*) /article/view?id=%1 [L,R=301]<?= GridView::widget([
    'pager' => [
        'firstPageLabel' => 'Начало',
        'lastPageLabel' => 'Конец',
    ],
]) ?>__get('type') (у родительского класса) для определения существования в рамках Yii атрибута или геттера getType() для получения значения этого атрибута: yii\db\BaseActiveRecord::__get()public function getType() {
    return $this->hasOne(Type::className(), ['id' => 'type_id']);
}