Jump to content

Custom page types, find and unpublished pages


Zeka
 Share

Recommended Posts

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...