コード例 #1
0
ファイル: PostType.php プロジェクト: fbarrento/yii2-content
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = PostTypeModel::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]);
     $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, 'post_type_smb' => $this->post_type_smb]);
     $query->andFilterWhere(['like', 'post_type_name', $this->post_type_name])->andFilterWhere(['like', 'post_type_slug', $this->post_type_slug])->andFilterWhere(['like', 'post_type_description', $this->post_type_description])->andFilterWhere(['like', 'post_type_icon', $this->post_type_icon])->andFilterWhere(['like', 'post_type_sn', $this->post_type_sn])->andFilterWhere(['like', 'post_type_pn', $this->post_type_pn])->andFilterWhere(['like', 'post_type_permission', $this->post_type_permission]);
     return $dataProvider;
 }
コード例 #2
0
 /**
  * Lists all Menu models.
  *
  * @param null $id
  *
  * @return mixed
  */
 public function actionIndex($id = null)
 {
     $model = new Menu();
     // list all post types
     $postTypes = PostType::find()->where(['post_type_smb' => 1])->all();
     // list all taxonomies
     $taxonomies = Taxonomy::find()->where(['taxonomy_smb' => 1])->all();
     // get available menu
     if ($availableMenu = ArrayHelper::map(Menu::find()->all(), 'id', 'menu_title')) {
         if ($id === null && $availableMenu) {
             foreach ($availableMenu as $key => $menu) {
                 $id = $key;
                 break;
             }
         }
         $selectedMenu = $this->findModel($id);
     }
     return $this->render('index', ['model' => $model, 'availableMenu' => $availableMenu, 'selectedMenu' => isset($selectedMenu) ? $selectedMenu : null, 'postTypes' => $postTypes, 'taxonomies' => $taxonomies]);
 }
コード例 #3
0
ファイル: reading.php プロジェクト: fbarrento/yii2-content
$form = ActiveForm::begin(['id' => 'option-reading-form', 'options' => ['class' => 'form-horizontal']]);
?>

        <div class="form-group">
            <?php 
echo Html::label(Yii::t('content', 'Front page displays'), null, ['class' => 'col-sm-2 control-label']);
?>
            <div class="col-sm-7">
                <?php 
echo Html::radioList('Option[show_on_front][option_value]', $model->show_on_front->option_value, ['posts' => Yii::t('content', 'Latest posts')], ['separator' => '<br />', 'class' => 'radio']);
?>
                <?php 
echo Html::label(Yii::t('content', 'Front page: '), 'option-front_page');
?>
                <?php 
echo Html::dropDownList('Option[front_post_type][option_value]', $model->front_post_type->option_value, ArrayHelper::merge(['all' => 'All'], ArrayHelper::map(PostType::find()->all(), 'post_type_name', 'post_type_sn')), ['class' => 'form-control']);
?>
            </div>

        </div>

        <div class="form-group">
            <div class="col-sm-7 col-sm-push-2">
                <?php 
echo Html::radioList('Option[show_on_front][option_value]', $model->show_on_front->option_value, ['page' => Yii::t('content', 'Static page')], ['separator' => '<br />', 'class' => 'radio']);
?>
                <?php 
echo Html::label(Yii::t('content', 'Front page: '), 'option-front_page');
?>
                <?php 
echo Html::dropDownList('Option[front_page][option_value]', $model->front_page->option_value, Post::findOne($model->front_page->option_value) ? ArrayHelper::map(Post::find()->select(['id', 'post_title'])->where(['id' => $model->front_page->option_value])->all(), 'id', 'post_title') : [], ['class' => 'search-post', 'disabled']);