Esempio n. 1
0
 /**
  * Finds the Banner model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Banner the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Banner::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Esempio n. 2
0
 public function actionPartners()
 {
     $this->layout = 'column2';
     $model = Banner::find()->all();
     if (!$model) {
         throw new NotFoundHttpException(\Yii::t('common', 'Page not found'));
     }
     return $this->render('partners', ['model' => $model]);
 }
Esempio n. 3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Banner::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 return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'img' => $this->img, 'type' => $this->type]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'link', $this->link])->andFilterWhere(['like', 'status', $this->status])->andFilterWhere(['like', 'description', $this->description]);
     return $dataProvider;
 }
Esempio n. 4
0
<?php

use yii\helpers\Html;
use yii\grid\GridView;
use backend\modules\banner\models\Banner;
/* @var $this yii\web\View */
/* @var $searchModel backend\modules\banner\models\BannerSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('backend', 'Banners');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="box box-primary">
    <div class="box-body">
    

        <p>
            <?php 
echo Html::a(Yii::t('backend', 'Create Banner'), ['create'], ['class' => 'btn btn-success']);
?>
        </p>
    
        <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'img', 'format' => 'raw', 'value' => function ($model, $key, $index, $column) {
    return Html::img('/storage/banner/' . $model->img, ['width' => '130px']);
}, 'contentOptions' => ['style' => 'width:160px;']], 'name', 'link', 'status', ['attribute' => 'type', 'filter' => Banner::getTypeArray(), 'value' => 'TypeName'], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{update} {delete}', 'contentOptions' => ['class' => 'actionColumn'], 'buttonOptions' => ['class' => 'btn btn-sm btn-default', 'style' => 'padding:1px 10px;']]]]);
?>

    </div>
</div>
Esempio n. 5
0
    <div class="box-body">

        <?php 
$form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]);
?>
        
        <div class="row">
            <div class="col-lg-4 col-md-6">
                <?php 
echo $form->field($model, 'name')->textInput(['maxlength' => true]);
?>
                <?php 
echo $form->field($model, 'link')->textInput(['maxlength' => true]);
?>
                <?php 
echo $form->field($model, 'type')->dropDownlist(Banner::getTypeArray());
?>
                <?php 
echo $form->field($model, 'status')->textInput(['maxlength' => true]);
?>
                <?php 
echo $form->field($model, 'img')->fileInput();
?>
                <?php 
if (!$model->isNewRecord) {
    ?>
                    <img src="<?php 
    echo Yii::$app->params['domainName'] . '/images/' . $model->img;
    ?>
" />
                <?php 
Esempio n. 6
0
        </div><!-- /.row -->
    </div><!-- /.container -->
</section><!-- /.section -->
    
    
<section id="partner" class="section middle-padding hidden-sm hidden-xs">
    <div class="container">
        <div class="row">
            <div class="col-md-3">
                <div class="heading-line color-info big"></div>
                <h2 class="lighter no-padding-top">Партнеры</h2>
            </div><!--/.col-->
            <div class="col-md-9 text-center info-partners">
                <div class="row">
        			<?php 
foreach (\backend\modules\banner\models\Banner::find()->orderBy('id ASC')->all() as $data) {
    ?>
                        <?php 
    if ($data->link) {
        ?>
                            <div class="col-md-3">
                                <a href="<?php 
        echo $data->link;
        ?>
" target="_blank">
                                    <img src="/images/<?php 
        echo $data->img;
        ?>
" />
                                </a>
                            </div>