本文整理汇总了PHP中Collection::lastPage方法的典型用法代码示例。如果您正苦于以下问题:PHP Collection::lastPage方法的具体用法?PHP Collection::lastPage怎么用?PHP Collection::lastPage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Collection
的用法示例。
在下文中一共展示了Collection::lastPage方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onRun
public function onRun()
{
$this->prepareVars();
$this->posts = $this->page['posts'] = $this->listPosts($this->property('slug'));
/*
* If the page number is not valid, redirect
*/
if ($pageNumberParam = $this->paramName('pageNumber')) {
$currentPage = $this->property('pageNumber');
if ($currentPage > ($lastPage = $this->posts->lastPage()) && $currentPage > 1) {
return Redirect::to($this->currentPageUrl([$pageNumberParam => $lastPage]));
}
}
}
示例2: onRun
public function onRun()
{
$this->prepareVars();
$this->category = $this->page['category'] = $this->loadCategory();
$this->articles = $this->page['articles'] = $this->listArticles();
/*
* If the page number is not valid, redirect
*/
if ($pageNumberParam = $this->paramName('pageNumber')) {
$currentPage = $this->property('pageNumber');
if ($currentPage > ($lastPage = $this->articles->lastPage()) && $currentPage > 1) {
return Redirect::to($this->currentPageUrl([$pageNumberParam => $lastPage]));
}
}
}
示例3: onRun
/**
* @see RainLab\Blog\Components\Posts::onRun()
* @return mixed
*/
public function onRun()
{
$this->prepareVars();
// map get request to :search param
$searchTerm = Input::get('search');
if (\Request::isMethod('get') && $searchTerm) {
// add ?cats[] query string
$cats = Input::get('cat');
$query = http_build_query(['cat' => $cats]);
$query = preg_replace('/%5B[0-9]+%5D/simU', '%5B%5D', $query);
$query = !empty($query) ? '?' . $query : '';
return Redirect::to($this->currentPageUrl([$this->searchParam => urlencode($searchTerm)]) . $query);
}
// load posts
$this->posts = $this->page['posts'] = $this->listPosts();
/*
* If the page number is not valid, redirect
*/
if ($pageNumberParam = $this->paramName('pageNumber')) {
$currentPage = $this->property('pageNumber');
if ($currentPage > ($lastPage = $this->posts->lastPage()) && $currentPage > 1) {
return Redirect::to($this->currentPageUrl([$pageNumberParam => $lastPage]));
}
}
}
示例4: onLoadPosts
/**
* Ajax pagination
* @return array
*/
public function onLoadPosts()
{
$this->prepareVars();
$is_last = Input::get('page', 1) >= $this->posts->lastPage() ? true : false;
$template = Input::get('template', $this->template);
return ['is-last' => $is_last, 'posts' => $this->posts, '@.post-load' => $this->renderPartial('fieldPosts::ajax', ['posts' => $this->posts, 'template' => $template])];
}
示例5: onRun
public function onRun()
{
$this->prepareVars();
/* $this->addCss('/plugins/zingabory/gallery/bower_components/photoswipe/dist/photoswipe.css');
$this->addJs('/plugins/zingabory/gallery/bower_components/photoswipe/dist/photoswipe.min.js');
$this->addJs('/plugins/zingabory/gallery/bower_components/photoswipe/dist/photoswipe-ui-default.min.js');*/
$this->category = $this->page['category'] = $this->loadCategory();
$this->galleries = $this->page['galleries'] = $this->listGalleries();
/*
* If the page number is not valid, redirect
*/
if ($pageNumberParam = $this->paramName('pageNumber')) {
$currentPage = $this->property('pageNumber');
if ($currentPage > ($lastPage = $this->galleries->lastPage()) && $currentPage > 1) {
return Redirect::to($this->currentPageUrl([$pageNumberParam => $lastPage]));
}
}
}
示例6: onRun
public function onRun()
{
$this->prepareVars();
try {
$this->category = $this->page['category'] = $this->loadCategory();
} catch (ModelNotFoundException $e) {
return App::make('Cms\\Classes\\Controller')->setStatusCode(404)->run('/404');
}
$this->posts = $this->page['posts'] = $this->listPosts();
/*
* If the page number is not valid, redirect
*/
if ($pageNumberParam = $this->paramName('pageNumber')) {
$currentPage = $this->property('pageNumber');
if ($currentPage > ($lastPage = $this->posts->lastPage()) && $currentPage > 1) {
return Redirect::to($this->currentPageUrl([$pageNumberParam => $lastPage]));
}
}
}
示例7: onRun
/**
* @see RainLab\Blog\Components\Posts::onRun()
* @return mixed
*/
public function onRun()
{
$this->prepareVars();
// map get request to :search param
$searchTerm = \Input::get('search');
if (\Request::isMethod('get') && $searchTerm) {
return Redirect::to($this->currentPageUrl([$this->searchParam => urlencode($searchTerm)]));
}
// load posts
$this->posts = $this->page['posts'] = $this->listPosts();
/*
* If the page number is not valid, redirect
*/
if ($pageNumberParam = $this->paramName('pageNumber')) {
$currentPage = $this->property('pageNumber');
if ($currentPage > ($lastPage = $this->posts->lastPage()) && $currentPage > 1) {
return Redirect::to($this->currentPageUrl([$pageNumberParam => $lastPage]));
}
}
}