public static function isLinkActive($menu, array $fields = [])
    {
        if ($menu instanceof ActiveRecord) {
            if (self::$pages === null) {
                self::initPages();
            }

            if (!$fields) {
                $fields = self::$fields;
            }

            /** Check if page_url is the same as current url */
            $pageUrl = $menu->{$fields['page_url']};
            if ($pageUrl) {
                if (strpos($pageUrl, 'http') === 0) {
                    return false;
                }

                return (Url::to([$pageUrl]) === Url::current());
            }

            if (isset(self::$pages[$menu->{$fields['page_id']}]['link'])) {
                if (Yii::$app->request->getQueryParam(self::$linkParam) === self::$pages[$menu->{$fields['page_id']}]['link']) {
                    return true;
                }

                return false;
            }

            return (Url::home() === Url::current());
        }

        return false;

    }
public static function isLinkActive($menu, array $fields = [])
    {
        if ($menu instanceof ActiveRecord) {
            if (self::$pages === null) {
                self::initPages();
            }

            if (!$fields) {
                $fields = self::$fields;
            }

            /** Check if page_url is the same as current url */
            $pageUrl = $menu->{$fields['page_url']};
            if ($pageUrl) {
                if (strpos($pageUrl, 'http') === 0) {
                    return false;
                }

                return (Url::to([$pageUrl]) === Url::current());
            }

            if (isset(self::$pages[$menu->{$fields['page_id']}]['link'])) {
                if (Yii::$app->request->getQueryParam(self::$linkParam) === self::$pages[$menu->{$fields['page_id']}]['link']) {
                    return true;
                }

                return false;
            }

            return (Url::home() === Url::current());
        }

        return false;

    }
public static function isLinkActive ( $ menu , array $ fields = [ ] ) { if ( $ menu instanceof ActiveRecord ) { if ( self :: $ pages === null ) { self :: initPages ( ) ; } if ( ! $ fields ) { $ fields = self :: $ fields ; } /** Check if page_url is the same as current url */ $ pageUrl = $ menu -> { $ fields [ 'page_url' ] } ; if ( $ pageUrl ) { if ( strpos ( $ pageUrl , 'http' ) === 0 ) { return false ; } return ( Url :: to ( [ $ pageUrl ] ) === Url :: current ( ) ) ; } if ( isset ( self :: $ pages [ $ menu -> { $ fields [ 'page_id' ] } ] [ 'link' ] ) ) { if ( Yii :: $ app -> request -> getQueryParam ( self :: $ linkParam ) === self :: $ pages [ $ menu -> { $ fields [ 'page_id' ] } ] [ 'link' ] ) { return true ; } return false ; } return ( Url :: home ( ) === Url :: current ( ) ) ; } return false ; }
Check if page is active
@param mixed $menu
@param array $fields
@return bool
@throws \yii\base\InvalidConfigException
Check if page is active