Exemple #1
0
 public function init()
 {
     parent::init();
     $mobile_detect = new MobileDetect();
     $this->is_mobile = $mobile_detect->isMobile();
     $this->is_tablet = $mobile_detect->isTablet();
     //        Yii::$app->language = 'vi-VN';
     $language = Language::getLanguage();
     $language_data = $language->getLanguageData();
     $currency_params = $language->getDefaultCurrencyParams();
     I18n::setLanguageData($language_data);
     I18n::setCurrencyParams($currency_params);
     Yii::$app->session->set('language_id', $language->id);
     $this->meta_index = 'index';
     $this->meta_follow = 'follow';
     $this->page_title = I18n::t('{page title}');
     $this->meta_title = I18n::t('{meta title}');
     $this->meta_description = I18n::t('{meta description}');
     $this->meta_keywords = I18n::t('{meta keywords}');
     $this->meta_image = Yii::$app->params['default_image'];
     Yii::$app->session->has('cart') or Yii::$app->session->set('cart', new Cart());
 }
Exemple #2
0
<?php

$params = array_merge(require __DIR__ . '/../../common/config/params.php', require __DIR__ . '/../../common/config/params-local.php', require __DIR__ . '/params.php', require __DIR__ . '/params-local.php');
return ['id' => 'app-frontend', 'basePath' => dirname(__DIR__), 'controllerNamespace' => 'frontend\\controllers', 'bootstrap' => ['log', 'gii'], 'modules' => ['gii' => ['class' => 'yii\\gii\\Module', 'generators' => ['model' => ['class' => 'common\\gii\\generators\\model\\Generator', 'templates' => ['custom' => __DIR__ . '/../../common/gii/generators\\model/default']], 'crud' => ['class' => 'common\\gii\\generators\\crud\\Generator', 'templates' => ['custom' => __DIR__ . '/../../common/gii/generators\\crud/default']]]]], 'bootstrap' => ['languagepicker'], 'components' => ['languagepicker' => ['class' => 'lajax\\languagepicker\\Component', 'languages' => function () {
    // List of available languages (icons and text)
    return \frontend\models\Language::getLanguages_codeToLabel();
}, 'cookieName' => 'language_id', 'expireDays' => 64, 'callback' => function () {
    if (!\Yii::$app->user->isGuest) {
        $user = \Yii::$app->user->identity;
        $user->language_id = \frontend\models\Language::getLanguage()->id;
        $user->save(false);
    }
}], 'request' => ['baseUrl' => ''], 'urlManager' => ['scriptUrl' => '/index.php', 'enablePrettyUrl' => true, 'showScriptName' => false, 'rules' => [['pattern' => '', 'route' => 'site/index'], ['pattern' => '', 'route' => 'site/index', 'suffix' => '/'], ['pattern' => 'danh-muc/<parent_slug>/<slug>', 'route' => 'product-category/detail'], ['pattern' => 'danh-muc/<parent_slug>/<slug>', 'route' => 'product-category/detail', 'suffix' => '/'], ['pattern' => 'danh-muc/<slug>', 'route' => 'product-category/detail'], ['pattern' => 'danh-muc/<slug>', 'route' => 'product-category/detail', 'suffix' => '/'], ['pattern' => 'bo-suu-tap', 'route' => 'product-collection/index'], ['pattern' => 'bo-suu-tap/', 'route' => 'product-collection/index', 'suffix' => '/'], ['pattern' => 'bo-suu-tap/<slug>.html', 'route' => 'product-collection/detail'], ['pattern' => 'san-pham/<slug>.html', 'route' => 'product/detail'], ['pattern' => 'gio-hang.html', 'route' => 'cart/index'], ['pattern' => 'gio-hang.html', 'route' => 'cart/index', 'suffix' => '/'], ['pattern' => 'gui-don-hang.html', 'route' => 'purchase-order/create'], ['pattern' => 'dang-nhap.html', 'route' => 'site/login'], ['pattern' => 'dang-xuat.html', 'route' => 'site/logout'], ['pattern' => 'dang-ky.html', 'route' => 'customer/create'], ['pattern' => 'dat-lai-mat-khau.html', 'route' => 'site/request-password-reset'], ['pattern' => 'u/<username>', 'route' => 'customer/index'], ['pattern' => 'u/<username>', 'route' => 'customer/index', 'suffix' => '/'], ['pattern' => 'u/<username>/cap-nhat-tai-khoan.html', 'route' => 'customer/update'], ['pattern' => 'kham-pha', 'route' => 'discovery/index'], ['pattern' => 'kham-pha/', 'route' => 'discovery/index', 'suffix' => '/'], ['pattern' => 'tim-kiem', 'route' => 'search/index'], ['pattern' => 'tim-kiem', 'route' => 'search/index', 'suffix' => '/'], ['pattern' => '<slug>', 'route' => 'general-info/detail']]], 'user' => ['identityClass' => 'frontend\\models\\Customer', 'enableAutoLogin' => true], 'log' => ['traceLevel' => YII_DEBUG ? 3 : 0, 'targets' => [['class' => 'yii\\log\\FileTarget', 'levels' => ['error', 'warning']]]], 'errorHandler' => ['errorAction' => 'site/error'], 'assetManager' => ['appendTimestamp' => true, 'bundles' => ['yii\\web\\JqueryAsset' => ['sourcePath' => null, 'basePath' => '@webroot', 'baseUrl' => '@web', 'js' => ['//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js']]]]], 'params' => $params];