Jump to content

Recommended Posts

Posted

I'm trying to move repeater items, simply change the parent id of each repeater item but I'm struggling to retrieve the actual ID of the repeater on the target page. (Not the field id, the repeater_page_id)

If the repeater on the target page is empty;

What i need is: $target_repeater_parent = $target_page->repeater_field->id;

So I can:
foreach($source_page->repeater_field as $item) {
 $item->parent = $target_repeater_parent;
 $item->save();
}

What am I missing here?

Posted

The repeater parent is not the page that calls the repeater item. To get the page that it appears on, you need to use 'getForPage()'

 

Posted
56 minutes ago, psy said:

The repeater parent is not the page that calls the repeater item. To get the page that it appears on, you need to use 'getForPage()'

 

getForPage() is used on an actual repeater item? The repeater is empty.

if i print_r($page->repeater); i can see the page parent in the selectors: parent_id=11686
This is ID is what I'm trying to retrieve.

ProcessWire\RepeaterPageArray Object ( [hooks] => Array ( [PageArray::render] => MarkupPageArray->renderPageArray() in MarkupPageArray.module [PageArray::renderPager] => MarkupPageArray->renderPager() in MarkupPageArray.module ) [count] => 0 [total] => 0 [start] => 0 [limit] => 0 [selectors] => parent_id=11686, templates_id=104, sort=sort )

 

[SOLVED] 
As simple as: $parent_id = $pages->get('name=for-page'.$page->id);

Posted

@Mackski - take a look at the "Copy or Move Repeater Items to Other Page" action in the AdminActions module. What you've done may work for some repeaters, but won't handle images if there is an image field involved.

  • Like 1

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