當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Tag::dealTag方法代碼示例

本文整理匯總了PHP中app\models\Tag::dealTag方法的典型用法代碼示例。如果您正苦於以下問題:PHP Tag::dealTag方法的具體用法?PHP Tag::dealTag怎麽用?PHP Tag::dealTag使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\models\Tag的用法示例。


在下文中一共展示了Tag::dealTag方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: foreach

if ($ask) {
    $i = 1;
    foreach ($ask as $v) {
        ?>
            <li class="list-group-item media col-sm-12 mt0">
                <div class="pull-right">
                <?php 
        echo html::tag('span', $v['cellectNum'], ['class' => 'badge badge-reply-count']) . '收藏';
        echo html::tag('span', $v['attentionNum'], ['class' => 'badge badge-reply-count']) . '關注';
        echo html::tag('span', $v['scanNum'], ['class' => 'badge badge-reply-count']) . '瀏覽';
        ?>
                </div>
                <div class="pull-right">
                <?php 
        if ($v['tags']) {
            $allTags = Tag::dealTag($v['tags'], true);
            foreach ($allTags as $k) {
                ?>
                <span class="badge badge-reply-count"><?php 
                echo $k;
                ?>
</span>
                <?php 
            }
        }
        ?>
                </div>
                <div class="avatar pull-left">
                    <a href="/member/ruzuojun"><img class="media-object" src="/uploads/avatars/cache/50_1SB1v6BlGNsO4b-1UnVyE2l3LzscfkLJ.jpg" alt=""></a>
                </div>
                <div class="infos">
開發者ID:kennygp,項目名稱:yii-myweb,代碼行數:31,代碼來源:indexs.php

示例2: actionCreate

 /**
  * 新增問題.
  * If creation is successful, the browser will be redirected to the 'view' page.
  *
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Main();
     $post = Yii::$app->request->post();
     if (isset($post['Main']['tags']) && isset($post['Main']['title']) && isset($post['Main']['content'])) {
         $tagReplace = Tag::dealTag($post['Main']['tags'], false);
         Tag::addTag(explode(',', $tagReplace));
         $model->load($post);
         $model->userId = Yii::$app->user->identity->getId();
         $model->createTime = date('Y-m-d H:i:s', time());
         $model->status = 3 == $post['Main']['type'] ? $post['Main']['status'] : 1;
         $model->scanNum = 0;
         $model->cellectNum = 0;
         $model->attentionNum = 0;
         $model->tags = $tagReplace;
         if ($model->save()) {
             if (1 == $post['Main']['type']) {
                 return $this->redirect(['index']);
             } elseif (2 == $post['Main']['type']) {
                 return $this->redirect(['article']);
             } else {
                 return $this->redirect(['note']);
             }
         }
     } else {
         $get = Yii::$app->request->get();
         $type = 1;
         if (isset($get['type'])) {
             if (2 == $get['type']) {
                 $title = '發表文章';
                 $type = 2;
             } else {
                 $title = '發表筆記';
                 $type = 3;
             }
         } else {
             $title = '發表問題';
         }
         return $this->render('create', ['model' => $model, 'title' => $title, 'type' => $type]);
     }
 }
開發者ID:kennygp,項目名稱:yii-myweb,代碼行數:47,代碼來源:MainController.php


注:本文中的app\models\Tag::dealTag方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。