<?php

use yii\helpers\Html;
use yii\grid\GridView;

/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = 'Recent Causes';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="recent-causes-index">

    <h1><?= Html::encode($this->title) ?></h1>

    <p>
        <?= Html::a('Create Recent Causes', ['create'], ['class' => 'btn btn-success']) ?>
    </p>

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],

            'id',
            'title',
            'shortContent',
            [
               'attribute' => 'image',
               'label' => 'Image.',
               'value' => function ($model) {
                   if(!empty($model->image))
                       return Html::img(Yii::$app->params['front_url'].'images/recentcauses/'.$model->image,["style"=>"width:100px;height:auto;"]);
                   return null;
               },
               'format' => "html",
           ],

            ['class' => 'yii\grid\ActionColumn'],
        ],
    ]); ?>

</div>
