本文整理汇总了PHP中DataList::limit方法的典型用法代码示例。如果您正苦于以下问题:PHP DataList::limit方法的具体用法?PHP DataList::limit怎么用?PHP DataList::limit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataList
的用法示例。
在下文中一共展示了DataList::limit方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sequenceGridListItems
/**
* @param \DataList|\ArrayList $items
* @param $filters
* @param array $parameters
*/
public function sequenceGridListItems(&$items, $filters, &$parameters = [])
{
$limit = isset($parameters['PageLength']) ? $parameters['PageLength'] : null;
// filter items for each filter to current page length
if ($limit) {
$start = GridList::service()->Filters()->start() ?: 0;
$out = new \ArrayList();
$currentFilter = GridList::service()->constraint(Constraints::FilterVar);
if ($currentFilter && $currentFilter != 'all') {
if ($filter = GridListFilter::get()->filter(['ModelTag' => $currentFilter])->first()) {
$out->merge($items->limit($limit, $start));
}
} else {
foreach ($filters as $filter) {
$filtered = new \ArrayList();
foreach ($items as $item) {
if ($item instanceof Block) {
// only push blocks first page
if ($start == 0) {
$filtered->push($item);
}
} else {
if ($currentFilter == 'all') {
$filtered->push($item);
} else {
if ($item->GridListFilters()->find('ID', $filter->ID)) {
$filtered->push($item);
}
}
}
}
// merge limited filtered items back in
$out->merge($filtered->limit($limit, $start));
}
}
$items = $out;
}
}
示例2: LimitGalleryItems
/**
* limits the number of displayed items
*
* @param DataList $galleryList
* @return DataList|SS_Limitable
*/
protected function LimitGalleryItems(DataList $galleryList)
{
$limit = Config::inst()->get('HeaderGalleryExtension', 'limit_header_images');
return $limit ? $galleryList->limit($limit) : $galleryList;
}
开发者ID:helpfulrobot,项目名称:wernerkrauss-silverstripe-header-gallery,代码行数:11,代码来源:HeaderGalleryExtension.php
示例3: limitCurrentFinalProducts
/**
* limits the products to a maximum number (for speed's sake)
* @return DataList (this->allProducts adjusted!)
*/
protected function limitCurrentFinalProducts()
{
$this->rawCount = $this->allProducts->count();
$max = EcommerceConfig::get("ProductGroup", "maximum_number_of_products_to_list");
if ($this->rawCount > $max) {
$this->allProducts = $this->allProducts->limit($max);
$this->totalCount = $max;
} else {
$this->totalCount = $this->rawCount;
}
return $this->allProducts;
}