TbMenu::init PHP Метод

init() публичный Метод

Initializes the widget.
public init ( )
    public function init()
    {
        parent::init();
        $classes = array('nav');
        $validTypes = array(self::TYPE_TABS, self::TYPE_PILLS, self::TYPE_LIST);
        if (isset($this->type) && in_array($this->type, $validTypes)) {
            $classes[] = 'nav-' . $this->type;
        }
        if ($this->stacked && $this->type !== self::TYPE_LIST) {
            $classes[] = 'nav-stacked';
        }
        if ($this->dropup === true) {
            $classes[] = 'dropup';
        }
        if (isset($this->scrollspy)) {
            $scrollspy = is_string($this->scrollspy) ? array('target' => $this->scrollspy) : $this->scrollspy;
            $this->widget('bootstrap.widgets.TbScrollSpy', $scrollspy);
        }
        if (!empty($classes)) {
            $classes = implode(' ', $classes);
            if (isset($this->htmlOptions['class'])) {
                $this->htmlOptions['class'] .= ' ' . $classes;
            } else {
                $this->htmlOptions['class'] = $classes;
            }
        }
    }

Usage Example

Пример #1
0
 /**
  * Initializes the widget.
  */
 public function init()
 {
     $languages = Yii::app()->getLanguages();
     $activeLocale = Yii::app()->language;
     $items = array(array('label' => 'Language'));
     foreach ($languages as $locale => $language) {
         if ($locale === $activeLocale) {
             $activeLanguage = $language;
         }
         $items[] = array('label' => $language, 'url' => array('/site/changeLanguage', 'locale' => $locale), 'active' => $locale === $activeLocale);
     }
     $label = isset($activeLanguage) ? $activeLanguage : 'Unknown';
     $this->items = array_merge(array(array('label' => $label, 'items' => $items)), $this->items);
     parent::init();
 }
All Usage Examples Of TbMenu::init