本文整理汇总了PHP中yii\bootstrap\Nav::isItemActive方法的典型用法代码示例。如果您正苦于以下问题:PHP Nav::isItemActive方法的具体用法?PHP Nav::isItemActive怎么用?PHP Nav::isItemActive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\bootstrap\Nav
的用法示例。
在下文中一共展示了Nav::isItemActive方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isItemActive
protected function isItemActive($item)
{
if (isset($item['url']) && is_string($item['url']) && $item['url'] === Url::current()) {
return true;
}
return parent::isItemActive($item);
}
示例2: isItemActive
/**
* Checks whether a menu item is active.
* This is done by checking if [[route]] and [[params]] match that specified in the `url` option of the menu item.
* When the `url` option of a menu item is specified in terms of an array, its first element is treated
* as the route for the item and the rest of the elements are the associated parameters.
* Only when its route and parameters match [[route]] and [[params]], respectively, will a menu item
* be considered active.
* @param array $item the menu item to be checked
* @return boolean whether the menu item is active
*/
protected function isItemActive($item)
{
if (isset($item['urlActive']) && is_array($item['urlActive'])) {
foreach ($item['urlActive'] as $auxUrl) {
$auxItem = $item;
$auxItem['url'] = $auxUrl;
if (parent::isItemActive($auxItem)) {
return true;
}
}
}
return parent::isItemActive($item);
}
示例3: isItemActive
/**
* @inheritdoc
*/
protected function isItemActive($item)
{
// Let the parent check if active.
$ret = parent::isItemActive($item);
// If not already active, check some other things.
if (!$ret && isset($item['url'][0])) {
$route = $item['url'][0];
if ($route[0] !== '/' && Yii::$app->controller) {
$route = Yii::$app->controller->module->getUniqueId() . '/' . $route;
}
$routeTrimmed = ltrim($route, '/');
// Also check if the index route.
$ret = $routeTrimmed . '/index' === $this->route;
// Also check if the user profile.
if (!$ret) {
// XXX: Workaround for user profile not following the convention.
$ret = $this->route === $routeTrimmed || strpos($this->route, $routeTrimmed . '/') !== false;
}
}
return $ret;
}
示例4: isItemActive
/**
* Adds additional checks
* @inheritdoc
*/
protected function isItemActive($item)
{
if (parent::isItemActive($item)) {
return true;
}
if (!isset($item['url'])) {
return false;
}
$route = null;
$itemUrl = $item['url'];
$requestUrl = Yii::$app->request->getUrl();
if (is_array($itemUrl) && isset($itemUrl[0])) {
$route = $itemUrl[0];
if ($route[0] !== '/' && Yii::$app->controller) {
$route = Yii::$app->controller->module->getUniqueId() . '/' . $route;
}
} else {
$route = $itemUrl;
}
$isActive = $route === $requestUrl;
return $isActive;
}
示例5: isItemActive
protected function isItemActive($item)
{
if (ArrayHelper::keyExists('active', $item)) {
return ArrayHelper::remove($item, 'active', false);
} else {
return parent::isItemActive($item);
// TODO: Change the autogenerated stub
}
}
示例6: isItemActive
/**
* @param array $item
* @return bool
*/
protected function isItemActive($item)
{
return isset($item['scope']) ? in_array(\Yii::$app->controller->id, $item['scope']) : parent::isItemActive($item);
}