Esempio n. 1
0
 public function actionCategory($id)
 {
     /**
      * Define default member group code
      */
     //get code id with max sum value
     $memberGroupCode = MembersCodesComponent::getMemberGroupCode();
     $memberAnswersCodes = MembersCodesComponent::getMemberCodesSqlFilter();
     $recipesQuery = CmsRecipes::find()->where(['is_active' => 1]);
     //add default group to exclude codes array
     if (!empty($memberGroupCode)) {
         $memberAnswersCodes['exclude'][] = ['not like', 'no_code_id', "[{$memberGroupCode}]"];
     }
     //add conditions to the where instance if exclude codes array not empty
     if (count($memberAnswersCodes['exclude']) > 0) {
         $recipesQuery->andWhere(array_merge(['and'], $memberAnswersCodes['exclude']))->orWhere(['no_code_id' => NULL]);
     }
     //add default group to include codes array
     if (!empty($memberGroupCode)) {
         $memberAnswersCodes['include'][] = ['like', 'code_id', "[{$memberGroupCode}]"];
     }
     //add conditions to the where instance if include codes array not empty
     if (count($memberAnswersCodes['include']) > 0) {
         $recipesQuery->andWhere(array_merge(['or'], $memberAnswersCodes['include']))->orWhere(['code_id' => '']);
     }
     $recipesQuery->andWhere(['like', 'category_id', "[{$id}]"]);
     $dataProvider = new ActiveDataProvider(['query' => $recipesQuery, 'sort' => ['defaultOrder' => ['sort_order' => SORT_ASC]]]);
     $category = CmsRecipesCategories::find($id)->one();
     return $this->render('index', ['dataProvider' => $dataProvider, 'category' => $category]);
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = CmsRecipesCategories::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'status' => $this->status, 'sort_order' => $this->sort_order, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'title', $this->title]);
     return $dataProvider;
 }
 /**
  * Finds the CmsRecipesCategories model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return CmsRecipesCategories the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = CmsRecipesCategories::find()->where(['id' => $id])->multilingual()->one()) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Esempio n. 4
0
    $field_meta_keywords = $form->field($model, "meta_keywords_{$language->url}")->textarea(['rows' => 4])->label(Yii::t('backend', 'Recipe Keywords'));
    $field_meta_description = $form->field($model, "meta_description_{$language->url}")->textarea(['rows' => 6])->label(Yii::t('backend', 'Recipe Description'));
    if ($languageDefault->url == $language->url) {
        $field_title = $form->field($model, "title")->textInput(['maxlength' => true]);
        $field_content = $form->field($model, 'content')->widget(\yii\redactor\widgets\Redactor::className(), ['clientOptions' => $redactorClientOptions]);
        $field_content_heading = $form->field($model, "content_heading")->textInput(['maxlength' => true]);
        $field_meta_keywords = $form->field($model, "meta_keywords")->textarea(['rows' => 4]);
        $field_meta_description = $form->field($model, "meta_description")->textarea(['rows' => 6]);
    }
    $language_items[] = ['label' => Yii::t('backend', $language->name), 'content' => "<p>{$field_title} {$field_content} {$field_content_heading} {$field_meta_keywords}</p>", 'active' => $language->url == Yii::$app->language];
}
echo Tabs::widget(['items' => $language_items]);
?>

    <?php 
echo $form->field($model, 'category_id')->dropDownList(ArrayHelper::map(\backend\models\CmsRecipesCategories::find()->all(), 'id', 'title'), ['multiple' => 'true', 'size' => 7])->label(Yii::t('backend', 'Select Categories'));
?>

    <?php 
echo $form->field($model, 'identifier')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'code_id')->dropDownList(ArrayHelper::map(MappingQuestionsCodes::find()->all(), 'id', 'code'), ['multiple' => 'true', 'size' => 7, 'prompt' => Yii::t('backend', 'Select Codes')]);
?>

    <?php 
echo $form->field($model, 'no_code_id')->dropDownList(ArrayHelper::map(MappingQuestionsCodes::find()->all(), 'id', 'code'), ['multiple' => 'true', 'size' => 7, 'prompt' => Yii::t('backend', 'Select Codes')]);
?>

    <?php