Jump to content

Pages on trash get selected through API


apeisa
 Share

Recommended Posts

I got this on my template:

foreach($page->related_people as $person) {
        echo "<h3><a href='{$person->url}'>{$person->title}</a></h3>";
}

If that related page is moved to trash, then output will be something like this:

<h3><a href='/trash/5785_title/'>Title</a></h3>

Probably not desired effect? Shouldn't pages on trash be always hidden or at least some way out of normal API-selectors?

Link to comment
Share on other sites

Good find. The FieldtypePage module was using a retrieval method without selectors, which bypassed the status check. I just added a status check to FieldtypePage, so that it will exclude pages with any status level above Unpublished (which includes Trash). Can you give it a try and let me know if it resolves it? Here is the change in the latest commit:

https://github.com/ryancramerdesign/ProcessWire/commit/6cb6bc19a6e2841264368e8239cbc054bdbebc9d#diff-0

Link to comment
Share on other sites

Thank you! Just updated and I can confirm that it works.

I like the fact that moving to trash doesn't remove page references that other pages has made to it. So if you have to undo your trashed page all relations are still working.

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