Jump to content
e0f

What is the best way for ...

Recommended Posts

Hi all guys,

I have pages son of a Page, all with same template.

In this template I have so many fields. I want to check if there are pages with the same value of 1 of this 3 fields (a, b, c) and if yes delete one of this.
The main intent is to remove all duplicates pages checking by fields.

Anyone can suggest me a way?

Thanks!

 

 

Share this post


Link to post
Share on other sites
<?PHP

/* single out with selectors the pages you want to target */
$pageArray = $pages->findMany('template=name_of_template, field_name=value);

/* iterate through the selected pages and do something to each of them */

foreach($pageArray AS $key => $myPage) {

	/* Do something with the page */

}

?>

Also check out the documentation for Selectors.
They are very powerfull and usefull.

https://processwire.com/docs/selectors/

Also check out the API docs for $page
https://processwire.com/api/ref/page/

And $pages
https://processwire.com/api/ref/pages/

The API docs are my first stop when i am trying to figure out to do something in PW.

Good luck.

 

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...