コード例 #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Taxonomy::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $query->andFilterWhere($params);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'url_alias', $this->url_alias])->andFilterWhere(['like', 'description', $this->description]);
     return $dataProvider;
 }
コード例 #2
0
ファイル: Takonomy.php プロジェクト: Nathanyang/lulucms2
 public static function getOneOrDefault($taxonomy)
 {
     $taxonomyModel = Taxonomy::findOne(['id' => $taxonomy]);
     if ($taxonomyModel === null) {
         $taxonomyModel = ['id' => null, 'name' => '所有'];
     }
     return $taxonomyModel;
 }
コード例 #3
0
 public function actionIndex()
 {
     $taxonomy = LuLu::getGetValue('taxonomy');
     $query = Content::find();
     $query->where(['content_type' => $this->content_type]);
     $query->andFilterWhere(['taxonomy_id' => $taxonomy]);
     if ($taxonomy === null) {
         $taxonomyModel = Taxonomy::findOne(['id' => $taxonomy]);
     } else {
         $taxonomyModel = ['id' => null, 'name' => '所有'];
     }
     $locals = LuLu::getPagedRows($query, ['orderBy' => 'created_at desc', 'pageSize' => 10]);
     $locals['taxonomyModel'] = $taxonomyModel;
     return $this->render('index', $locals);
 }
コード例 #4
0
ファイル: _form.php プロジェクト: hucongyang/lulucms2
<?php

use yii\helpers\Html;
use source\core\widgets\ActiveForm;
use source\models\Content;
use source\models\Taxonomy;
use source\libs\Common;
/* @var $this yii\web\View */
/* @var $model app\models\Content */
/* @var $form yii\widgets\ActiveForm */
$filedOptions = ['template' => "{label}{input}\n{error}", 'labelOptions' => ['class' => 'control-label']];
$taxonomies = Taxonomy::getArrayTree('post');
$options = Common::buildTreeOptions($taxonomies, $model->taxonomy_id);
?>

<div class="content-form ">



    <?php 
$form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data'], 'fieldConfig' => ['template' => "{label}<div class=\"col-md-8\">{input}</div>\n{error}", 'labelOptions' => ['class' => 'col-md-4 control-label no-padding-left no-padding-right align-left']]]);
?>
    
<div class="row">
		<div class="col-md-9">
		    <?php 
echo $form->field($model, 'title', $filedOptions)->textInput(['maxlength' => 256, 'placeholder' => '请输入标题'])->label(false);
?>
		
		    <?php 
echo $form->field($model, 'url_alias', $filedOptions)->textInput(['maxlength' => 128, 'placeholder' => 'Url 地址']);
コード例 #5
0
ファイル: ContentBody.php プロジェクト: hucongyang/lulucms2
 public function getTaxonomy()
 {
     return $this->hasOne(Taxonomy::className(), ['id' => 'taxonomy_id']);
 }
コード例 #6
0
ファイル: takonomy.php プロジェクト: hucongyang/lulucms2
<?php

use yii\web\View;
use yii\helpers\Html;
use yii\helpers\Url;
use source\libs\Resource;
use source\models\Content;
use source\models\Taxonomy;
use source\LuLu;
/* @var $this yii\web\View */
$moduleId = LuLu::$app->controller->module->id;
$taxonomies = Taxonomy::getArrayTree($this->getConfigValue($moduleId . '_taxonomy'));
if (!empty($taxonomies)) {
    ?>
    <h3 class="widget-title">分类</h3>
    <div class="hot widget">
        <ul>
            <li><?php 
    echo Html::a('所有', ['/' . $moduleId . '/default/list']);
    ?>
</li>
            <?php 
    foreach ($taxonomies as $taxonomy) {
        ?>
            <li><?php 
        echo Html::a($taxonomy['name'], ['/' . $moduleId . '/default/list', 'taxonomy' => $taxonomy['id']]);
        ?>
</li>
            <?php 
    }
    ?>
コード例 #7
0
ファイル: takonomy.php プロジェクト: hucongyang/lulucms2
<?php

use yii\web\View;
use yii\helpers\Html;
use yii\helpers\Url;
use source\libs\Resource;
use source\models\Content;
use source\models\Taxonomy;
use source\LuLu;
/* @var $this yii\web\View */
if (isset($taxonomyId)) {
    $moduleId = LuLu::$app->controller->module->id;
    $taxonomies = Taxonomy::getArrayTree($this->getConfigValue($taxonomyId));
    ?>

<div class="widget d_postlist">
    <div class="title">
        <h2>分类</h2>
    </div>
    <ul>
        <li><?php 
    echo Html::a('所有', ['/' . $moduleId . '/default/list']);
    ?>
</li>
        <?php 
    foreach ($taxonomies as $taxonomy) {
        ?>
        <li><?php 
        echo Html::a($taxonomy['name'], ['/' . $moduleId . '/default/list', 'taxonomy' => $taxonomy['id']]);
        ?>
</li>
コード例 #8
0
 public function beforeDelete()
 {
     Taxonomy::deleteAll(['category_id' => $this->id]);
     return true;
 }
コード例 #9
0
 /**
  * Finds the Taxonomy model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Taxonomy the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Taxonomy::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }