Zeka Posted January 20, 2020 Share Posted January 20, 2020 Hi. I begin to rewrite hooks to custom pages types and have found out an issue with find method. My custom PagesType class doesn't implement find method and inherits it from PagesType class. which relies on $pages->find By default $pages->find method exclude hidden and unpublished pages, but if I call find on my custom PagesType it returns also unpublished pages, but not hidden. In code: class Posts extends PagesType { public function __construct(ProcessWire $wire, $templates = array(), $parents = array()) { parent::__construct($wire, $templates, $parents); $this->setWire($wire); $this->addTemplates("post"); // templates_id=51 $this->addParents($this->pages->get("template=posts")->id); // parent_id=1036, $this->setPageClass('Post'); } } // in home.php $news = wire('posts')->find('sort=-publish_from, limit=500'); // selectors => "sort=-publish_from, limit=500, parent_id=1036, templates_id=51" // returns 489 items including unpublished pages, but excluding hidden pages $news = wire('pages')->find('sort=-publish_from, limit=500, parent_id=1036, templates_id=51'); // selectors => "sort=-publish_from, limit=500, parent_id=1036, templates_id=51" // returns 480 items excluding unpublished and hidden pages Probably I missing something obvious, but I can't understand why it behaves in this way. In PagesClass::find I don't see anything that can affect on Pages::find. Maybe it's intended behavior with PagesType? Thanks, Eugene. Link to comment Share on other sites More sharing options...
Robin S Posted January 20, 2020 Share Posted January 20, 2020 3 hours ago, Zeka said: In PagesClass::find I don't see anything that can affect on Pages::find. This maybe? if(!isset($options['findAll'])) $options['findAll'] = true; https://processwire.com/api/ref/pages/find/ findAll (boolean): Find all pages with no exclusions, same as "include=all" option (default=false). 1 Link to comment Share on other sites More sharing options...
Zeka Posted January 21, 2020 Author Share Posted January 21, 2020 @Robin S This is terrible. I don’t know how I overlooked it, сause I've looked at this part so many times Thanks! 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now