本文整理匯總了PHP中menu::model方法的典型用法代碼示例。如果您正苦於以下問題:PHP menu::model方法的具體用法?PHP menu::model怎麽用?PHP menu::model使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類menu
的用法示例。
在下文中一共展示了menu::model方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getData
public function getData($cnd = " = 0")
{
$data = array();
foreach (menu::model()->findAll('parent_id' . $cnd) as $model) {
$row['text'] = $model->title;
$row['id'] = $model->id;
$row['children'] = Menu::getData(' =' . $model->id);
$data[] = $row;
}
return $data;
}
示例2: AND
<?php
if (!Yii::app()->user->isGuest) {
if (Yii::app()->user->name == 'admin') {
$Hierarchy = menu::model()->findAll(array('condition' => 'parent_id = \'0\' AND (name = \'m2\' OR name = \'m0\') ', 'order' => 'sort'));
} else {
$Hierarchy = menu::model()->findAllBySql('SELECT a.id FROM s_module a
LEFT JOIN s_user_module b ON a.id = b.s_module_id
WHERE a.parent_id = "0"
AND b.s_user_id = ' . Yii::app()->user->id . ' order by sort');
}
foreach ($Hierarchy as $Hierarchy) {
$models = menu::model()->findBypk($Hierarchy->id);
$items[] = $models->getListed();
}
$this->widget('bootstrap.widgets.BootNavbar', array('brand' => Yii::app()->name, 'brandUrl' => Yii::app()->createUrl("menu"), 'collapse' => true, 'items' => array(array('class' => 'bootstrap.widgets.BootMenu', 'items' => $items), array('class' => 'bootstrap.widgets.BootMenu', 'htmlOptions' => array('class' => 'pull-right'), 'items' => array(array('label' => Yii::app()->user->name, 'icon' => 'icon-th', 'url' => '#', 'items' => array(array('label' => 'Help', 'icon' => 'question-sign', 'url' => Yii::app()->createUrl("sAdmin/help"), 'visible' => Yii::app()->user->name == "admin"), '---', array('label' => 'Profile', 'icon' => 'road', 'url' => Yii::app()->createUrl('/sUser/viewPublic', array('id' => Yii::app()->user->id))), array('label' => 'Theme', 'icon' => 'road', 'url' => '#'), array('label' => 'Bookmark', 'icon' => 'list', 'url' => '#'), array('label' => 'Version', 'icon' => 'info-sign', 'url' => Yii::app()->createUrl("menu/version")), array('label' => 'About', 'icon' => 'qrcode', 'url' => Yii::app()->createUrl("menu/about")), '---', array('label' => 'Log Out', 'icon' => 'off', 'url' => Yii::app()->createUrl("site/logout")))))))));
} else {
$this->widget('bootstrap.widgets.BootNavbar', array('brand' => Yii::app()->name, 'brandUrl' => '#', 'collapse' => true, 'items' => array()));
}