Jump to content

Excluding fields in repeater when copying using API


Recommended Posts


I have a small module I created that copies across field content from one page to multiple other pages.

I just added a repeater field and while it copies across to the other pages it has caused timeout/memory issues with PHP. I think this is because of the multiple fields within the repeater (title, text caption, image) each being copied multiple times.

I thought one way to help would be to not copy images across as they're not needed in the other pages.

However I'm unable to figure out how to copy a repeater field excluding one field within the repeater itself.

This is my current code:

// Inline gallery 1
          if(count($page->article_inline_gallery_1)) {
            $gallery = $page->article_inline_gallery_1;
            foreach($gallery as $item) {

At the point that each repeater imported as a whole ->import($item) could anyone help to exclude one of the fields within the repeater?

Link to comment
Share on other sites

  • 1 year later...

More than a year later.....

From the docs


Remove a repeater item in exactly the same way you remove an item from any other PageArray: 

$building = $page->buildings->first(); // or whatever item you want to remove


  • Like 1
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

  • Create New...