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])); } } }
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])); } } }
/** * @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])); } } }
/** * 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])]; }
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])); } } }
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])); } } }
/** * @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])); } } }