/**
  * @include
  * @noCall
  * @documentation Apply a named filter from the page's config (similar to `posts_filters`).
  */
 public function filter($filterName)
 {
     $page = $this->rootLinker->getPage();
     if ($page == null) {
         throw new PieCrustException("Can't use 'filter()' because no parent page was set for the linker iterator.");
     }
     if (!$page->getConfig()->hasValue($filterName)) {
         throw new PieCrustException("Couldn't find filter '{$filterName}' in the configuration header for page: {$page->getPath()}");
     }
     $filterDefinition = $page->getConfig()->getValue($filterName);
     $filter = new PaginationFilter();
     $filter->addClauses($filterDefinition);
     $this->innerIterator = new ConfigFilterIterator($this->innerIterator, $filter, function ($data) {
         return $data->getPage();
     });
     return $this;
 }
Beispiel #2
0
 protected function filterClauses($clauses)
 {
     $this->ensureUnlocked();
     $this->unload();
     $filter = new PaginationFilter();
     $filter->addClauses($clauses);
     $this->iterator = new ConfigFilterIterator($this->iterator, $filter);
     return $this;
 }
 /**
  * @include
  * @noCall
  * @documentation Only return posts with given tags.
  */
 public function with_tags($tag1, $tag2)
 {
     $this->unload();
     $tagClauses = array();
     $argCount = func_num_args();
     for ($i = 0; $i < $argCount; ++$i) {
         $tag = func_get_arg($i);
         $tagClauses['has_tags'] = $tag;
     }
     $filter = new PaginationFilter();
     $filter->addClauses(array('and' => $tagClauses));
     $this->modifierChain[] = new FilterIteratorModifier($filter);
     return $this;
 }
Beispiel #4
0
 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;
 }
Beispiel #5
0
 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;
 }