Mackski Posted March 18, 2021 Share Posted March 18, 2021 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? Link to comment Share on other sites More sharing options...
psy Posted March 18, 2021 Share Posted March 18, 2021 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()' Link to comment Share on other sites More sharing options...
Mackski Posted March 18, 2021 Author Share Posted March 18, 2021 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); Link to comment Share on other sites More sharing options...
adrian Posted March 18, 2021 Share Posted March 18, 2021 @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. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now