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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...