[moka同学笔记]yii2.0的下拉菜单与bootstrap下拉菜单

1.yii2下拉菜单

1             <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">管理<b class="caret"></b></a>
2                 <ul class="dropdown-menu">
3                     <li><?= Html::a(‘新建文章‘, [‘article/create‘]) ?></li>
4                     <li><a href="<?=Url::toRoute([‘article/list‘]);?>">管理文章</a></li>
5                     <li><a href="#">添加栏目</a></li>
6                     <li><a href="<?=Url::toRoute([‘article-category/index‘]);?>">管理栏目</a></li>
7                 </ul>
8             </li>

2.bootrap下拉菜单

 1                 <?php
 2                 use yii\bootstrap\ButtonDropdown;
 3                 echo ButtonDropdown::widget([
 4                     ‘label‘ => ‘操作‘,
 5                     ‘dropdown‘ => [
 6                         ‘items‘ => [
 7                             [‘label‘ => ‘文章列表‘, ‘url‘ => Url::toRoute([‘article/list‘])],
 8                             [‘label‘ => ‘栏目列表‘, ‘url‘ => Url::toRoute([‘article-category/index‘])],
 9                         ],
10                     ],
11                 ]);?>

时间: 2024-10-12 00:36:49

[moka同学笔记]yii2.0的下拉菜单与bootstrap下拉菜单的相关文章

[moka同学笔记]yii2.0小物件的简单使用(第二种方法)

1.在widgets/TestWidget.php中 1 <?php 2 /** 3 * Created by PhpStorm. 4 * User: moka同学 5 * Date: 2016/08/05 6 * Time: 18:15 7 */ 8 namespace app\widgets; 9 10 use yii\base\Widget; 11 12 class TestWidget extends Widget 13 { 14 public $msg = ''; 15 16 //初始

[moka同学笔记]Yii2.0给一张表中增加一个属性

1.model中建立关联 public function getUser(){ return$this->hasOne(User::className(),['id'=>'uid']) ; } 2.在视图中 <?= GridView::widget([ 'dataProvider' => $dataProvider, 'columns' => [ // ['class' => 'yii\grid\SerialColumn'], 取消掉编号 ['attribute'=&g

[moka同学笔记]yii2.0 dropdownlist的简单使用

1.controller控制中 $modelCountrytelCode = CountryTelCode::find()->orderBy('id DESC')->all(); $telCode = ArrayHelper::map($modelCountrytelCode,'area_code','name'); //显示name,传值area_code ***********其他代码************ return $this->render('createUser', [

[moka同学笔记]yii2场景的使用(摘录)

前半部分为自己使用的过程,下边为转载的,具体地址见:http://blog.sina.com.cn/s/blog_88a65c1b0101j717.html 1.在model中 public function rules() { return [ [['join_verify', 'create_activity', 'is_open_group', 'is_open_child_com','sendmail_limit','sendmail_from_name','sendmail_from'

[moka同学笔记]Yii2 自定义class、自定义全局函数(摘录)

1.在app\components下新建MyComponent.PHP namespace app\components; use Yii; use yii\base\Component; use yii\base\InvalidConfigException; class MyComponent extends Component { public function welcome() { echo "Hello..Welcome to MyComponent"; } } 2.在co

[moka学习笔记]yii2.0数据库查询的多种方法(未完待整理)

方法一:(使用model) $modelCommunityMail = CommunityMail::find()->where(['com_id'=>$id])->all(); 方法二:(直接拼写sql语句) $sql = "select * from `usho_community_mail` where date_format(`created_at`,'%Y%m') = date_format(curdate() ,'%Y%m') AND `com_id`=$id AN

[moka同学笔记]三、Yii2.0课程笔记(魏曦老师教程)

关联字段增加搜索 post表关联adminuser表,通过post.author_id  adminuser.id关联,在YII2.0生成搜索,关联字段搜索时,需要输入关联字段author的id才能搜索,这不符合我们的要求,我们要求输入作者名就可以搜索出来,该作者对应的post.

[moka同学笔记]redis练习Demo

<?php /** * Created by PhpStorm. * User: moka同学 * Date: 2017/3/13 * Time: 10:54 */ echo 'Hello redis'.'<br>'; $redis = new Redis(); $redis->connect("127.0.0.1","6379"); //demo1 /*$redis->set("name","This i

[moka同学笔记]window下.htacess文件 与linux下.htacess文件

windows下 # Turn on URL rewritingRewriteEngine On # Installation directoryRewriteBase / # Protect hidden files from being viewed<Files .*>    Order Deny,Allow    Deny From All</Files> # Protect application and system files from being viewedRewr