本文整理汇总了PHP中yii\widgets\ListView::widget方法的典型用法代码示例。如果您正苦于以下问题:PHP ListView::widget方法的具体用法?PHP ListView::widget怎么用?PHP ListView::widget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\widgets\ListView
的用法示例。
在下文中一共展示了ListView::widget方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
$ret_val = '';
if (isset($this->header) && is_string($this->header) && !is_bool($this->header)) {
$ret_val = Html::tag('h2', $this->header);
}
switch ($this->displayAs) {
case 'grid':
$this->items = is_array($this->items) ? $this->items : [$this->items];
$this->widgetOptions = array_merge(['summary' => false, 'layout' => '{items}', 'showHeader' => $this->header, 'dataProvider' => new \yii\data\ArrayDataProvider(['allModels' => $this->items]), 'columns' => $this->attributes], $this->widgetOptions);
$ret_val .= \kartik\grid\GridView::widget($this->widgetOptions);
break;
case 'list':
$this->widgetOptions = array_merge(['itemOptions' => ['tag' => false], 'summary' => false, 'dataProvider' => new \yii\data\ArrayDataProvider(['allModels' => $this->items]), 'itemView' => function ($model, $key, $index, $widget) {
return $this->renderListItem($model, $key, $index, $widget);
}], $this->widgetOptions);
$ret_val .= \yii\widgets\ListView::widget($this->widgetOptions);
break;
case 'csv':
$ret_val = [];
foreach ($this->items as $index => $item) {
$ret_val[] = $this->renderCsvItem($item, $index);
}
$ret_val = Html::tag('div', implode(', ', $ret_val));
break;
case 'tags':
foreach ($this->items as $index => $item) {
$ret_val .= $this->renderTagItem($item, $index);
}
$ret_val = Html::tag('div', $ret_val);
break;
default:
$this->widgetOptions['class'] = isset($this->widgetOptions['class']) ? $this->widgetOptions['class'] : 'table';
$this->widgetOptions = array_merge(['model' => $this->items, 'attributes' => $this->attributes, 'options' => ['class' => 'table']], $this->widgetOptions);
$ret_val .= \yii\widgets\DetailView::widget($this->widgetOptions);
break;
}
return $ret_val;
}
示例2: run
public function run()
{
$header = Html::tag(ArrayHelper::remove($this->labelOptions, 'tag', 'h4'), 'Parents', $this->labelOptions);
if (count($this->labelContainerOptions)) {
$header = Html::tag(ArrayHelper::remove($this->labelContainerOptions, 'tag', 'div'), $header, $this->labelContainerOptions);
}
$list = ListView::widget(['summary' => false, 'emptyText' => Html::tag('ul', '', $this->options), 'options' => $this->options, 'itemOptions' => $this->itemOptions, 'dataProvider' => $this->dataProvider, 'itemView' => function ($model, $key, $index, $widget) {
return $model->name . (!$this->viewOnly ? Html::tag('span', Html::a("Remove " . Icon::show('remove'), '/' . $this->model->isWhat() . "/remove-parent/" . $this->model->getId() . '/' . $model['id'], ['role' => 'parentListItem', 'style' => 'color:white']), ['class' => 'badge']) : '');
}]);
if (count($this->listOptions)) {
$list = Html::tag(ArrayHelper::remove($this->listOptions, 'tag', 'div'), $list, $this->listOptions);
}
if (!$this->viewOnly) {
$script = Html::tag('script', new \yii\web\jsExpression('$(document).ready(function () {
$("#' . $this->options['id'] . '").find(\'[role="parentListItem"]\').each(function () {
$(this).on("click", function (event) {
event.preventDefault();
var $element = $(this);
$.post(this.href, function (result) {
if(result) $element.parents("li").remove();
});
});
});
})'), ['type' => 'text/javascript']);
} else {
$script = '';
}
return Html::tag('div', $header . $list, $this->containerOptions) . $script;
}
示例3: testLabelsExplicit
public function testLabelsExplicit()
{
$dataProvider = new ActiveDataProvider(['query' => Order::find(), 'models' => [new Order()], 'totalCount' => 1, 'sort' => ['attributes' => ['total'], 'route' => 'site/index']]);
ob_start();
echo ListView::widget(['dataProvider' => $dataProvider, 'layout' => "{sorter}"]);
$actualHtml = ob_get_clean();
$this->assertFalse(strpos($actualHtml, '<a href="/index.php?r=site%2Findex&sort=customer_id" data-sort="customer_id">Customer</a>') !== false);
$this->assertTrue(strpos($actualHtml, '<a href="/index.php?r=site%2Findex&sort=total" data-sort="total">Invoice Total</a>') !== false);
}
示例4: run
public function run()
{
$this->view->registerJs('function refreshGpGallery() {
$(".gpgallery").collagePlus({"targetHeight": 250, "allowPartialLastRow": true, "childrenFilterSelector": ".inline"});
$(".gpgallery").collageCaption({"images": $(".inline:not(:has(div))")});
}
$(window).load(function() { refreshGpGallery(); });
$(window).resize(function() { refreshGpGallery(); });');
echo ListView::widget(['dataProvider' => $this->dataProvider, 'itemOptions' => ['tag' => false], 'itemView' => $this->itemView, 'layout' => "<div class=\"gpgallery\">{items}</div>\n{pager}", 'pager' => ['class' => \kop\y2sp\ScrollPager::className(), 'triggerOffset' => 999999, 'noneLeftText' => 'No more item to display', 'noneLeftTemplate' => '<div class="clearfix"></div><div class="ias-noneleft" style="text-align: center;"><small class="text-muted">{text}</small>', 'enabledExtensions' => [\kop\y2sp\ScrollPager::EXTENSION_TRIGGER, \kop\y2sp\ScrollPager::EXTENSION_SPINNER, \kop\y2sp\ScrollPager::EXTENSION_NONE_LEFT], 'eventOnRendered' => "function() { refreshGpGallery(); }"]]);
}
示例5: if
</td>
<td class="c23">
<h1><?php
echo Html::encode($model->title);
?>
</h1>
<?//= Html::img('/image/bannerfans_15821322.jpg', ['width'=>'100%']); ?>
<p><?php
echo Html::encode($model->description);
?>
<br><br></p>
<? if (!(Yii::$app->user->isGuest)) Pjax::begin(['id' => 'notes']); ?>
<?php
echo ListView::widget(['dataProvider' => $products, 'itemOptions' => ['class' => '_product'], 'layout' => "{items}\n{pager}\n", 'itemView' => '//product/_product', 'viewParams' => array('groups' => $groups)]);
?>
<? if (!(Yii::$app->user->isGuest)) Pjax::end(); ?>
</td>
</tr>
</table>
<?php
echo Html::input('hidden', 'this_category_id', $model->category_id, $options = ['class' => 'this_category_id']);
echo Html::input('hidden', 'group_this_category_id', $model->category_id, $options = ['class' => 'group_this_category_id']);
?>
示例6:
?>
</div>
<div class="col col15 t-right"><?php
echo Yii::t('app', 'CABINET_HISTORY_TRANSACTIONS_CHANGE');
?>
</div>
<div class="col col15 t-right"><?php
echo Yii::t('app', 'CABINET_HISTORY_TRANSACTIONS_AFTER');
?>
</div>
<div class="col col40"></div>
<div class="clr"></div>
</div>
<?php
echo ListView::widget(['dataProvider' => $dataProvider, 'itemView' => '_transaction-item', 'summary' => '', 'id' => 'items-list', 'itemOptions' => ['class' => 'item clearfix'], 'layout' => '{items}{pager}']);
?>
<?/*
<div class="item">
<div class="col col20">21:00 / 21.07.2015</div>
<div class="col col10 t-right">10.11$</div>
<div class="col col10 t-right"><b class="red">− 10$</b></div>
<div class="col col10 t-right"><b class="blue">0.11$</b></div>
<div class="col col-text col50">«Не стреляют? А как насчет джигитов с кинжалами?» — сразу спросили мы у Ольги, которая вместе с супругом недавно </div>
<div class="clr"></div>
</div>
<div class="item">
<div class="col col20">21:00 / 21.07.2015</div>
<div class="col col10 t-right">10.11$</div>
<div class="col col10 t-right"><b class="red">− 10$</b></div>
示例7: function
/* @var $this yii\web\View */
/* @var $searchModel pendalf89\filemanager\models\Mediafile */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->params['moduleBundle'] = FilemanagerAsset::register($this);
?>
<header id="header"><span class="glyphicon glyphicon-picture"></span> <?php
echo Module::t('main', 'File manager');
?>
</header>
<div id="filemanager" data-url-info="<?php
echo Url::to(['file/info']);
?>
">
<?php
echo ListView::widget(['dataProvider' => $dataProvider, 'layout' => '<div class="items">{items}</div>{pager}', 'itemOptions' => ['class' => 'item'], 'itemView' => function ($model, $key, $index, $widget) {
return Html::a(Html::img($this->context->module->routes['baseUrl'] . $model->path, ['width' => 50, 'height' => 50]) . '<span class="checked glyphicon glyphicon-check"></span>', '#mediafile', ['data-key' => $key]);
}]);
?>
<div class="dashboard">
<p><?php
echo Html::a('<span class="glyphicon glyphicon-upload"></span> ' . Module::t('main', 'Upload manager'), ['file/uploadmanager'], ['class' => 'btn btn-default']);
?>
</p>
<div id="fileinfo">
</div>
</div>
</div>
示例8:
<?php
/* @var $this yii\web\View */
$this->title = Yii::t('frontend', 'Articles');
echo $this->render('_typehead');
?>
<div id="article-index">
<h1><?php
echo Yii::t('frontend', 'Articles');
?>
</h1>
<?php
echo \yii\widgets\ListView::widget(['dataProvider' => $dataProvider, 'pager' => ['hideOnSinglePage' => true], 'itemView' => '_item']);
?>
</div>
示例9:
} else {
echo "RESULT";
}
?>
</h3>
<div class="sort">
<form id="sort-tour" class="form-inline" action="<?php
echo \yii\helpers\Url::to(['tour/sort']);
?>
" method="post" role="form">
<div class="form-group">
<label for="sort_tour">Sorting Tour</label>
<select name="sort-tour" id="sort" class="form-control">
<option value="">None</option>
<option value="Descending">Descending</option>
<option value="Ascending">Ascending</option>
</select>
<?php
echo $sort->link('length', ['id' => 'length_desc', 'class' => 'sr-only']);
?>
</div>
</form>
</div>
<div class="thumb-content">
<?php
echo ListView::widget(['dataProvider' => $provider, 'summary' => '', 'itemView' => '_show']);
?>
</div>
</div>
</div>
示例10: ArrayDataProvider
<div class="col-lg-12">
<h1 class="page-header">Company: <?= $model->name?></h1>
</div>
<!-- /.col-lg-12 -->
</div>
<!-- /.row -->
<?php
$dataProvider = $model->companyDetails;
echo ListView::widget([
'dataProvider' => new ArrayDataProvider(['allModels' => $dataProvider,'pagination' => false]),
'itemView' => '_row1',
'summary' => false,
'itemOptions' => [
'class' => 'col-lg-3 col-md-6'
],
'options' => [
'class' => 'row',
'id' => false
]
])?>
<!-- /.row -->
<div class="row">
<div class="col-lg-8">
<div class="chat-panel panel panel-green">
<div class="panel-heading">
<i class="fa fa-comments fa-fw"></i>
Latest Dealer Bids
<div class="btn-group pull-right">
</div>
</div>
示例11:
?>
<hr>
<?php
echo $this->render('tmpl/_total_income', ['budgetModel' => $model, 'type' => \app\models\BudgetItem::TYPE_INCOME]);
?>
<?php
echo $this->render('tmpl/modal_income', ['budgetModel' => $model, 'modelHistory' => $modelHistory]);
?>
</div>
<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
<!-- costs -->
<?php
echo ListView::widget(['dataProvider' => $providerCost, 'itemView' => 'tmpl/_cost']);
?>
<hr>
<?php
echo $this->render('tmpl/_total_costs', ['budgetModel' => $model, 'type' => \app\models\BudgetItem::TYPE_COST]);
?>
<?php
echo $this->render('tmpl/modal_costs', ['budgetModel' => $model, 'modelHistory' => $modelHistory]);
?>
</div>
</div>
</div>
</div>
</div>
示例12: function
<?php
use yii\helpers\Html;
use yii\widgets\ListView;
use yii\widgets\Pjax;
/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Гостевая книга';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="guest-book-index">
<h1><?php
echo Html::encode($this->title);
?>
</h1>
<?php
echo $this->render('_form', ['model' => $model]);
Pjax::begin(['id' => 'guest_records']);
?>
<?php
echo ListView::widget(['dataProvider' => $dataProvider, 'itemOptions' => ['class' => 'item'], 'itemView' => function ($model, $key, $index, $widget) {
// return Html::a(Html::encode($model->name), ['view', 'id' => $model->id]);
return $this->render('_list', ['model' => $model, 'index' => $index]);
}]);
Pjax::end();
?>
</div>
示例13:
* @author Semenov Alexander <semenov@skeeks.com>
* @link http://skeeks.com/
* @copyright 2010 SkeekS (СкикС)
* @date 25.05.2015
*/
/* @var $this yii\web\View */
/* @var $widget \skeeks\cms\cmsWidgets\contentElements\ContentElementsCmsWidget */
?>
<!-- /Latest Blog Post -->
<h4 class="letter-spacing-1"><?php
echo $widget->label;
?>
</h4>
<? echo \yii\widgets\ListView::widget([
'dataProvider' => $widget->dataProvider,
'itemView' => 'article-footer-item',
'emptyText' => '',
'options' =>
[
'tag' => 'ul',
'class' => 'footer-posts list-unstyled',
],
'itemOptions' => [
'tag' => false
],
'layout' => "{items}"
])?>
示例14:
<?php
use yii\widgets\ListView;
echo ListView::widget(['summary' => '', 'dataProvider' => $coloursProvider, 'itemOptions' => ['class' => 'item'], 'itemView' => '_color_item']);
示例15:
?>
<div class="row">
<div class="forum-category col-md-12">
<div class="header2">
<?php
echo $forum->name;
?>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<?php
echo ListView::widget(['summary' => false, 'itemView' => '_topic', 'id' => 'yboardTopic', 'dataProvider' => $dataProvider]);
?>
</div>
</div>
<div>
<?php
echo $this->render('_forumfooter');
?>
</div>
</div>
<div style="display:none;">
<?php
if (Yii::$app->user->can('moderator')) {