protected function getPaginationFilter() { $filter = new PaginationFilter(); $filterInfo = $this->page->getConfig()->getValue('posts_filters'); if ($filterInfo == 'none' or $filterInfo == 'nil' or $filterInfo == '') { $filterInfo = null; } if (PageHelper::isTag($this->page) or PageHelper::isCategory($this->page)) { // If the current page is a tag/category page, add filtering // for that. $filter->addPageClauses($this->page, $filterInfo); } else { if ($filterInfo != null) { // Add custom filtering clauses specified by the user in the // page configuration header. $filter->addClauses($filterInfo); } } return $filter; }
public function getOutputPath(IPage $page) { $bakePath = $this->bakeDir; $isSubPage = $page->getPageNumber() > 1; $decodedUri = rawurldecode($page->getUri()); if ($this->prettyUrls) { // Output will be one of: // - `uri/name/index.html` (if not a sub-page). // - `uri/name/<n>/index.html` (if a sub-page, where <n> is the page number). // This works also for URIs with extensions, as it will produce: // - `uri/name.ext/index.html` // - `uri/name.ext/2/index.html` $bakePath .= $decodedUri . ($decodedUri == '' ? '' : '/'); if ($isSubPage) { $bakePath .= $page->getPageNumber() . '/'; } $bakePath .= self::BAKE_INDEX_DOCUMENT; } else { // Output will be one of: // - `uri/name.html` (if not a sub-page). // - `uri/name/<n>.html` (if a sub-page, where <n> is the page number). // If the page has an extension different than `.html`, use that instead, like so: // - `uri/name.ext` // - `uri/name/<n>.ext` // (So in all examples, `name` refers to the name without the extension) $name = $decodedUri; $extension = pathinfo($decodedUri, PATHINFO_EXTENSION); if ($extension) { // If the page is a tag/category listing, we don't want to pick // up any extension from the tag/category name itself! (like if // the tag's name is `blah.php`) if (!PageHelper::isTag($page) && !PageHelper::isCategory($page)) { $name = substr($name, 0, strlen($name) - strlen($extension) - 1); } else { $extension = false; } } if ($decodedUri == '') { // For the homepage, we have: // - `uri/index.html` // - `uri/2.html` (if a sub-page) if ($isSubPage) { $bakePath .= $page->getPageNumber(); } else { $bakePath .= 'index'; } } else { $bakePath .= $name; if ($isSubPage) { $bakePath .= '/' . $page->getPageNumber(); } } $bakePath .= '.' . ($extension ? $extension : 'html'); } return $bakePath; }
protected function getPaginationFilter() { $filter = new PaginationFilter(); $filterInfo = $this->page->getConfig()->getValue('posts_filters'); if ($filterInfo == 'none' or $filterInfo == 'nil' or $filterInfo == '') { $filterInfo = null; } if (PageHelper::isTag($this->page) or PageHelper::isCategory($this->page)) { // If the current page is a tag/category page, add filtering // for that. if ($filterInfo != null) { throw new PieCrustException("The `posts_filters` setting cannot be used on a tag or category listing page -- the filter will be automatically set to posts matching the request tag or category."); } $filter->addPageClauses($this->page); } else { if ($filterInfo != null) { // Add custom filtering clauses specified by the user in the // page configuration header. $filter->addClauses($filterInfo); } } return $filter; }