Browse Source

Fixes #2361: `yii\bootstrap\NavBar::brandUrl` should default to the home URL of application

tags/2.0.0-beta
Qiang Xue 11 years ago
parent
commit
d183d5f2ed
  1. 1
      CHANGELOG.md
  2. 7
      NavBar.php

1
CHANGELOG.md

@ -4,6 +4,7 @@ Yii Framework 2 bootstrap extension Change Log
2.0.0 beta under development 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 #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 #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) - Enh #1601: Added support for tagName and encodeLabel parameters in ButtonDropdown (omnilight)

7
NavBar.php

@ -7,6 +7,7 @@
namespace yii\bootstrap; namespace yii\bootstrap;
use Yii;
use yii\helpers\Html; use yii\helpers\Html;
/** /**
@ -43,9 +44,9 @@ class NavBar extends Widget
public $brandLabel; public $brandLabel;
/** /**
* @param array|string $url the URL for the brand's hyperlink tag. This parameter will be processed by [[Html::url()]] * @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. * @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 Html::beginTag('div', ['class' => 'navbar-header']);
echo $this->renderToggleButton(); echo $this->renderToggleButton();
if ($this->brandLabel !== null) { 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'); echo Html::endTag('div');

Loading…
Cancel
Save