Jump to content

How to avoid trashed pages in find?


cpx3
 Share

Recommended Posts

Hi to all,

I have a very annoying problem: The selector 

$p = $pages->get("template=data-newsletter-subscribers,email=$strMail");

will always find and update pages that are trashed, even if there exists a none trashed version. What am I doing wrong?

Thanks in advance,

Bernhard

Link to comment
Share on other sites

6 hours ago, cpx3 said:
$p = $pages->get("template=data-newsletter-subscribers,email=$strMail");
5 hours ago, cpx3 said:

What am I doing wrong?

Hello,

Probably, it is the find() or a "similar method" (which also begins with the word find) is the one which you should use, not get(), see: https://processwire.com/api/ref/pages/

$pages->get() : Returns the first page matching the given selector with no exclusions.

Meaning with get() you get one page only without checking any kind of status nor access control.

 

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