コード例 #1
0
ファイル: Node.php プロジェクト: nsdown/getyii
 public function run()
 {
     $nodes = [];
     $parents = ArrayHelper::map(PostMeta::find()->where(['parent' => null])->orWhere(['parent' => 0])->orderBy(['order' => SORT_ASC])->all(), 'id', 'name');
     foreach ($parents as $key => $value) {
         $nodes[$value] = PostMeta::find()->where(['parent' => $key])->asArray()->all();
     }
     return $this->render('node', ['nodes' => $nodes]);
 }
コード例 #2
0
ファイル: PostMetaSearch.php プロジェクト: tqsq2005/getyii
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = PostMeta::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'count' => $this->count, 'order' => $this->order, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'alias', $this->alias])->andFilterWhere(['like', 'type', $this->type])->andFilterWhere(['like', 'description', $this->description]);
     return $dataProvider;
 }
コード例 #3
0
ファイル: Node.php プロジェクト: grutabow/getyii
 public function run()
 {
     $cacheKey = md5(__METHOD__);
     if (false === ($items = \Yii::$app->cache->get($cacheKey))) {
         $parents = ArrayHelper::map(PostMeta::find()->where(['parent' => null])->orWhere(['parent' => 0])->orderBy(['order' => SORT_ASC])->all(), 'id', 'name');
         foreach ($parents as $key => $value) {
             $nodes[$value] = PostMeta::find()->where(['parent' => $key])->asArray()->all();
         }
         $items = $nodes;
         //一天缓存
         \Yii::$app->cache->set($cacheKey, $items, 86400, new TagDependency(['tags' => [NamingHelper::getCommonTag(PostMeta::className())]]));
     }
     return $this->render('node', ['nodes' => $items]);
 }
コード例 #4
0
ファイル: Post.php プロジェクト: pramana08/app-cms
 /**
  * Update meta data for current post.
  *
  * @param $meta_name
  * @param $meta_value
  *
  * @return bool
  */
 public function upMeta($meta_name, $meta_value)
 {
     $model = PostMeta::find()->andWhere(['meta_name' => $meta_name])->andWhere(['post_id' => $this->id])->one();
     if (is_array($meta_value) || is_object($meta_value)) {
         $meta_value = Json::encode($meta_value);
     }
     $model->meta_value = $meta_value;
     return $model->save();
 }
コード例 #5
0
ファイル: search.php プロジェクト: tqsq2005/getyii
<?php

use yii\helpers\Html;
use yii\widgets\ListView;
use yii\widgets\Pjax;
use frontend\widgets\TopicSidebar;
use kartik\icons\Icon;
Icon::map($this);
$this->title = '社区';
$keyword = Yii::$app->request->getQueryParam('keyword');
if ($node = Yii::$app->request->getQueryParam('node')) {
    $node = \common\models\PostMeta::find()->where(['alias' => $node])->one();
}
?>
<div class="col-md-10 topic">
    <div class="panel panel-default">
        <?php 
if ($node) {
    ?>
            <div class="panel-heading clearfix">
                <?php 
    echo Icon::show('cloud-upload');
    ?>
 <?php 
    echo $node->name;
    ?>
                <?php 
    if (!empty($node->description)) {
        ?>
                    <br/>
                    <span style="color: #666666; font-size: 12px;"><?php