当前位置: 首页>>代码示例>>PHP>>正文


PHP Category::getAllCategories方法代码示例

本文整理汇总了PHP中app\models\Category::getAllCategories方法的典型用法代码示例。如果您正苦于以下问题:PHP Category::getAllCategories方法的具体用法?PHP Category::getAllCategories怎么用?PHP Category::getAllCategories使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\models\Category的用法示例。


在下文中一共展示了Category::getAllCategories方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionUpdate

 /**
  * Updates an existing Category model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $category_array = Category::getAllCategories();
     $category_array = ['0' => '顶级分类'] + $category_array;
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $id]);
     } else {
         return $this->render('update', ['model' => $model, 'category_array' => $category_array]);
     }
 }
开发者ID:heartshare,项目名称:yii2-crazydb-blog,代码行数:17,代码来源:CategoryController.php

示例2: array

 */
use yii\web\View;
use yii\helpers\Url;
use yii\data\ActiveDataProvider;
use yii\widgets\LinkPager;
use app\models\Post;
use app\models\Category;
/* @var View $this */
/* @var Post $posts */
/* @var string $tag */
/* @var ActiveDataProvider $dataProvider */
$this->params['breadcrumbs'] = [['label' => '所有标签', 'url' => Url::to(['tag/list'])], '标签'];
$sum = $dataProvider->totalCount;
$this->title = '标签:' . $tag;
$seo_description = "标签:{$tag}。该标签下共有{$sum}篇文章,";
$categories = Category::getAllCategories();
$post_names = array();
echo <<<HTML5
<header class="tag-info list-header">
    <h1><em class="glyphicon glyphicon-tag"></em>{$tag}  <small>共 {$sum} 篇</small></h1>
</header>
HTML5;
$posts = $dataProvider->models;
foreach ($posts as $post) {
    echo $this->render('/post/_article', array('post' => $post, 'category' => $categories[$post->cid]));
    $post_names[] = $post->title;
}
echo LinkPager::widget(['pagination' => $dataProvider->pagination]);
if (empty($this->params['seo_keywords'])) {
    $this->params['seo_keywords'] = $tag;
} else {
开发者ID:heartshare,项目名称:yii2-crazydb-blog,代码行数:31,代码来源:show.php

示例3:

echo $form->field($model, 'alias')->textInput(['maxlength' => true]);
?>
        </div>
        <div class="col-md-12 col-lg-4">
            <?php 
echo $form->field($model, 'author_name')->textInput(['maxlength' => true]);
?>
        </div>
    </div>
    <?php 
echo $form->field($model, 'cover', ['template' => '{label}<div class="input-group"><span class="input-group-btn"><button id="cover-upload" type="button" class="btn btn-success">上传图片</button></span>{input}</div>'])->textInput(['maxlength' => true]);
?>
    <div class="row">
        <div class="col-md-12 col-lg-3">
            <?php 
echo $form->field($model, 'cid')->dropDownList(Category::getAllCategories());
?>
        </div>
        <div class="col-md-12 col-lg-3">
            <?php 
echo $form->field($model, 'status')->dropDownList(Post::getAvailableStatus());
?>
        </div>
        <div class="col-md-12 col-lg-3">
            <?php 
echo $form->field($model, 'type')->dropDownList(Post::getAvailableType());
?>
        </div>
        <div class="col-md-12 col-lg-3">
            <?php 
echo $form->field($model, 'is_top')->dropDownList(['0' => '普通', '1' => '置顶']);
开发者ID:heartshare,项目名称:yii2-crazydb-blog,代码行数:31,代码来源:_form.php

示例4: function

<?php

use yii\helpers\Html;
use yii\grid\GridView;
use app\models\Category;
use app\models\Post;
/* @var $this yii\web\View */
/* @var $searchModel app\models\PostSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = '文章管理';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="box post-index">
    <div class="box-header with-border">
        <?php 
echo Html::a('发表新文章', ['create'], ['class' => 'btn btn-success']);
?>
    </div>
    <div class="box-body">
        <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'tableOptions' => ['class' => 'table table-bordered table-hover'], 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'title', ['attribute' => 'cid', 'value' => 'postCategory', 'filter' => Html::activeDropDownList($searchModel, 'cid', ['' => '全部'] + Category::getAllCategories(), ['class' => 'form-control'])], ['attribute' => 'author_id', 'value' => function ($model, $key, $index, $column) {
    return $model->author ? $model->author->nickname : null;
}], ['attribute' => 'is_top', 'format' => 'html', 'value' => function ($model, $key, $index, $column) {
    return $model->is_top ? '<span class="label label-success">置顶</span>' : '';
}, 'filter' => Html::activeDropDownList($searchModel, 'is_top', ['' => '全部', '0' => '否', '1' => '是'], ['class' => 'form-control'])], ['attribute' => 'status', 'value' => 'postStatus', 'filter' => Html::activeDropDownList($searchModel, 'status', ['' => '全部'] + Post::getAvailableStatus(), ['class' => 'form-control'])], ['attribute' => 'comment_count', 'filter' => false], ['attribute' => 'view_count', 'filter' => false], ['attribute' => 'post_time', 'format' => ['date', 'php:Y-m-d H:i:s'], 'filter' => false], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{view}&nbsp;&nbsp;{update}']]]);
?>
    </div>
</div>
开发者ID:heartshare,项目名称:yii2-crazydb-blog,代码行数:28,代码来源:index.php

示例5: getPostCategory

 /**
  * 获得文章所属分类
  * @return string|null
  */
 public function getPostCategory()
 {
     $categories = Category::getAllCategories();
     return isset($categories[$this->cid]) ? $categories[$this->cid] : null;
 }
开发者ID:heartshare,项目名称:yii2-crazydb-blog,代码行数:9,代码来源:Post.php


注:本文中的app\models\Category::getAllCategories方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。