我想在advanced-yii2中做多主题.我为此尝试了很多方法,但它不起作用我无法理解.首先,我将其添加到"frontend/config/main.php";
'view' => [
'theme' => [
'pathMap' => [
'@app/views' => [
'@webroot/themes/demo/views',
]
],
],
],
Run Code Online (Sandbox Code Playgroud)
并且它不起作用,然后我尝试为前端创建一个新的视图类,例如:
namespace frontend\components;
class NewsView extends \yii\web\View {
function init() {
\Yii::$app->view->viewPath = '@webroot/themes';
parent::init();
}
}
Run Code Online (Sandbox Code Playgroud)
并在config.php中添加
'view' => [
'class' => 'frontend\components\NewsView',
Run Code Online (Sandbox Code Playgroud)
但它也不起作用.
我该怎么办?
刚才,我尝试了添加链接到导航栏的内容.例如;
menuItems[] = ['label' => 'Test', 'url' => ['http://www.google.com']];
Run Code Online (Sandbox Code Playgroud)
但是我看到,任何时候yii2都会将baseUrl添加到每个地址.我也是这样做的;
文件:\ vendor\yiisoft\yii2\helpers\BaseHtml.php
之前:
public static function a($text, $url = null, $options = [])
{
if ($url !== null) {
$options['href'] = Url::to($url);
}
return static::tag('a', $text, $options);
}
Run Code Online (Sandbox Code Playgroud)
后:
public static function a($text, $url = null, $options = [])
{
if ($url !== null) {
$options['href'] = Url::to($url,'http');
}
return static::tag('a', $text, $options);
}
Run Code Online (Sandbox Code Playgroud)
它正在工作,但我不知道,这是真的吗?你怎么看?