Skip to content

Instantly share code, notes, and snippets.

View martins-giberts's full-sized avatar

Martins Giberts martins-giberts

View GitHub Profile
@martins-giberts
martins-giberts / SeoText
Created May 19, 2017 09:11
Multilanguage module for easyii
<?php
namespace app\modules\admin\models;
use Yii;
use app\modules\admin\validators\EscapeValidator;
use omgdef\multilingual\MultilingualBehavior;
class SeoText extends \app\modules\admin\components\ActiveRecord {
public static function tableName()
{
@martins-giberts
martins-giberts / SeoText localization migration
Last active May 19, 2017 09:19
Migration file for SeoText localization
<?php
use yii\db\Migration;
use yii\db\Schema;
use app\modules\admin\models\SeoText;
class add_seo_localization extends Migration
{
public $engine = 'ENGINE=MyISAM DEFAULT CHARSET=utf8';
public $table_name = 'easyii_seotext_lang';
@martins-giberts
martins-giberts / SeoFormView
Created May 19, 2017 09:31
Example Form view for SeoText table
<?php
use yii\bootstrap\BootstrapPluginAsset;
use yii\helpers\Html;
BootstrapPluginAsset::register($this); = ['class' => 'control-label'] = ['class' => 'form-control'];
?>
<p>
<a class="dashed-link collapsed" data-toggle="collapse" href="#seo-form" aria-expanded="false" aria-controls="seo-form"><?= Yii::t('easyii', 'Seo texts')?></a>
</p>
@martins-giberts
martins-giberts / UrlManager
Created May 19, 2017 09:40
Yii custom UrlManager. I am not the author of this class it was extract from another public project, but I have forgotten the real source.
<?php
namespace app\components;
use Yii;
use yii\base\InvalidConfigException;
use yii\web\Cookie;
use yii\web\UrlManager as BaseUrlManager;
/**
@martins-giberts
martins-giberts / URL config
Created May 19, 2017 09:43
Url configuration setup for Yii language switcher
// ...
'urlManager' => [
'class' => 'app\components\UrlManager',
'rules' => [
// ...
],
'enableDefaultLanguageUrlCode' => true,
'languages' => ['lv', 'en', 'ru'],
]
// ...
@martins-giberts
martins-giberts / sync stuff
Created August 20, 2017 16:03
sync stuff
sync stuff