I'm trying to get the datas from a table which those datas are using by another view and i was wondering if i could show them in my Yii2 Index
page view like each item with a cardview and details.
Exactly like my previous answer about that: https://stackoverflow.com/a/33847647/4960200
Is this possible?
Where or how can I use the datas from that table in my Yii2 index
?
Or honestly, I couldn't do that in my views/site/index.php
like this:
<div class="container" style="margin-top: 10px; background-color: white">
<div class="row">
<a class="btn btn-raised btn-sm btn-success pull-right" style="margin-right: 20px;margin-top: 20px">MORE</a>
<h3 style="margin-left: 20px">Something</h3>
<div class="container" style="margin-top: 20px">
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
[
'attribute' => 'yuor_attibute', // you can use a dummy attribute in this case
'label' => 'your label',
'format' => 'raw',
'value' => function ($model) {
return "<a href='./yourPath/view?id=". $model->your_column ."' class = 'btn btn-success glyphicon glyphicon-user ' > </a>";
},
'contentOptions' => ['style' => 'width:80px; text-align: center;'],
'headerOptions' => ['style' => 'text-align: center;'],
],
[
'attribute' => 'yuor_attibute', // you can use a dummy attribute in this case
'label' => 'your 2 label',
'format' => 'raw',
'value' => function ($model) {
return "<img src='./yourPath/image.jpg">";
},
'contentOptions' => ['style' => 'width:400; height 400 px;'],
'headerOptions' => ['style' => 'text-align: center;'],
],
[
'attribute' => 'yuor_attibute', // you can use a dummy attribute in this case
'label' => 'your 3 label',
'format' => 'raw',
'value' => function ($model) {
return "< ****the html you prefer ***>";
},
'contentOptions' => ['style' => 'width:400; height 400 px;'],
'headerOptions' => ['style' => 'text-align: center;'],
],
</div>
</div>
What should I learn about using this in my index and showing those datas from a table in index?