Exemplo n.º 1
0
<?php

$follow = \common\models\Follow::Node(false);
if (!empty($follow)) {
    ?>
<section>
    <div class="block-header"><small>我收藏的节点</small></div>
    <?php 
    $follow = \common\models\Follow::Node(false);
    ?>
    <?php 
    foreach ($follow as $f) {
        ?>
        <article class="sidebar">
            <table cellpadding="0" cellspacing="0" border="0" width="100%">
                <tbody><tr>
                    <td width="24" valign="middle" align="center">
                        <a href="/node/<?php 
        echo $f['enname'];
        ?>
"><img src="<?php 
        echo Yii::$app->params['nodeUrl'] . '/24/' . $f['logo'];
        ?>
" class="img-rounded"></a>
                    </td>
                    <td width="10"></td>
                    <td width="auto" valign="middle">
                <a href="/node/<?php 
        echo $f['enname'];
        ?>
"><?php 
Exemplo n.º 2
0
 public function actionNode()
 {
     $this->title = '收藏的节点的建议' . ' - ' . Yii::$app->name;
     $this->description = '';
     if (Yii::$app->user->isGuest) {
         return $this->redirect('/account/login?next=/account/node');
     }
     $query = (new Query())->select('topic.*, node.enname, node.name, user.username, user.avatar')->from(Topic::tableName())->leftJoin(Node::tableName(), 'node.id = topic.node_id')->leftJoin(User::tableName(), 'user.id = topic.user_id')->where(['in', 'node.id', Follow::Node()]);
     $pagination = new Pagination(['defaultPageSize' => Yii::$app->params['pageSize'], 'totalCount' => $query->count()]);
     $model = $query->orderBy(['id' => SORT_DESC])->offset($pagination->offset)->limit($pagination->limit)->all();
     return $this->render('node', ['model' => $model, 'pagination' => $pagination]);
 }
Exemplo n.º 3
0
 /**
  * 获取我收藏的节点
  * @param bool $onlyId
  * @return array|\yii\db\ActiveRecord[]
  */
 static function Node($onlyId = true)
 {
     if ($onlyId) {
         if (!($FollowNode = Yii::$app->cache->get('FollowNodeId' . Yii::$app->user->id))) {
             $FollowNode = ArrayHelper::map(Follow::find()->select('follow_id')->where(['user_id' => Yii::$app->user->id, 'type' => 2])->asArray('follow_id')->all(), 'follow_id', 'follow_id');
             Yii::$app->cache->set('FollowNodeId' . Yii::$app->user->id, $FollowNode, 0);
         }
     } else {
         if (!($FollowNode = Yii::$app->cache->get('FollowNode' . Yii::$app->user->id))) {
             $FollowNode = (new Query())->from(Node::tableName())->select('node.enname, node.name, node.logo')->where(['in', 'id', Follow::Node()])->all();
             Yii::$app->cache->set('FollowNode' . Yii::$app->user->id, $FollowNode, 0);
         }
     }
     return $FollowNode;
 }