1- frontend
klasörü içinde "themes" adında yeni bir klasör oluştur ve tema dosyalarını(assets, css, js, images, fonts) içine koy.
2- frontend/config/main.php
dosyasına aşağıda ki kodu ekle:
use \yii\web\Request;
$baseUrl = str_replace('/frontend/web', '', (new Request)->getBaseUrl());
3- frontend/config/main.php
içinde components dizisi içine aşağıdaki kodları ekle:
'view' => [
'theme' => [
'basePath' => '@app/themes',
'baseUrl' => '@web/frontend/web/../themes',
'pathMap' => [
'@app/views' => '@app/themes/views',
],
],
],
'request' => [
'baseUrl' => $baseUrl,#/frontend/web url'den silinecek
],
4- frontend/views/layouts/main.php
kodlarını tema ile ana sayfa ile değiş ve içinde eklenmesi gereken kodlar:
- -beginPage()
- -beginBody()
- -endBody()
- -endPage()
<?php $this->beginPage() ?>
<!DOCTYPE html>
<body>
<?php $this->beginBody() ?>
<?php $this->endBody() ?>
</body>
</html>
<?php $this->endPage() ?>
5- frontend/views/layouts/main.php
içinde head
tagları arasına aşağıda ki kodları ekleyebilirsiniz.
<head>
<meta charset="<?= Yii::$app->charset ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<?= Html::csrfMetaTags() ?>
<title><?= Html::encode($this->title) ?></title>
<?php $this->head() ?>
</head>
<?=$this->theme->baseUrl?>
7- çağrılacak sayfayı $content değişkeni ile çağırabilirsiniz.