Jump to content

exclude pages in trash from queries


bbeer
 Share

Recommended Posts

Hi all

would need to exclude children of the trash to appear in queries. Tried it with 

("parent!=49")

where parent id is the trash. Does not work with find nor get.

Your help is much appreciated.

Link to comment
Share on other sites

The ID of trash is 7, not 49. Depending on your need, you could do:

$untrashedPages = $pages->find("template=some-template, status<" . Page::statusTrash);
//$untrashedPages = $pages->find("template=some-template, has_parent!=7");
//$untrashedPages = $pages->find("template=some-template, has_parent!=" . $config->trashPageID);

FYI, statusTrash = 8192

  • Like 5
Link to comment
Share on other sites

I am surprised you are seeing trashed pages returned in a find call in the first place. Are you using "include=all" in the selector as well - I think that is the only way it will return trashed items.

Link to comment
Share on other sites

Hi adrian

sorry for the late reply. Well the problem was not directly that the page itself was listet. We output information from the page, if not there we check in the pages parent field for the content. The problem was, even though the page was in the trash, the values where still taken from that page, and not from the new, actually copy of that page. As soon as the trash was emptied, the problem was solved. Excluded the the trash now from the query, so hopefully we won't have that kind of occurrence again.

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...