From d183d5f2edda1d75fdccaeb4267e3fa980ac9720 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Fri, 7 Feb 2014 16:20:45 -0500 Subject: [PATCH] Fixes #2361: `yii\bootstrap\NavBar::brandUrl` should default to the home URL of application --- CHANGELOG.md | 1 + NavBar.php | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 58fc73d..669725a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ Yii Framework 2 bootstrap extension Change Log 2.0.0 beta under development ---------------------------- +- Bug #2361: `yii\bootstrap\NavBar::brandUrl` should default to the home URL of application (qiangxue) - Enh #1474: Added option to make NavBar 100% width (cebe) - Enh #1553: Only add navbar-default class to NavBar when no other class is specified (cebe) - Enh #1601: Added support for tagName and encodeLabel parameters in ButtonDropdown (omnilight) diff --git a/NavBar.php b/NavBar.php index 56616ea..7af9b89 100644 --- a/NavBar.php +++ b/NavBar.php @@ -7,6 +7,7 @@ namespace yii\bootstrap; +use Yii; use yii\helpers\Html; /** @@ -43,9 +44,9 @@ class NavBar extends Widget public $brandLabel; /** * @param array|string $url the URL for the brand's hyperlink tag. This parameter will be processed by [[Html::url()]] - * and will be used for the "href" attribute of the brand link. Defaults to site root. + * and will be used for the "href" attribute of the brand link. If not set, [[\yii\web\Application::homeUrl]] will be used. */ - public $brandUrl = '/'; + public $brandUrl; /** * @var array the HTML attributes of the brand link. */ @@ -84,7 +85,7 @@ class NavBar extends Widget echo Html::beginTag('div', ['class' => 'navbar-header']); echo $this->renderToggleButton(); if ($this->brandLabel !== null) { - echo Html::a($this->brandLabel, $this->brandUrl, $this->brandOptions); + echo Html::a($this->brandLabel, $this->brandUrl === null ? Yii::$app->homeUrl : $this->brandUrl, $this->brandOptions); } echo Html::endTag('div');