Publisher does not support the Fluid field type. Please do not contact asking when support will be available.
If you purchased an add-on from expressionengine.com, be sure to visit boldminded.com/claim to add the license to your account here on boldminded.com.
Ticket: Cloning with WCloner
Status | Resolved |
Add-on / Version | Bloqs 4.8 |
Severity | |
EE Version | 6.0.6 |
Luke David
Aug 04, 2021I’ve got another one that really isn’t your issue, but I thought I’d give it a shot. I’m using an addon that is no longer supported called WCloner. There is code in place that looks like it handles cloning entries with bloqs. However when you clone, it doesn’t keep the nested structure. I’ve looked into it a bit and have noticed that it copies the parent_ids from the initial entry instead up updating them to the new one. Is there any way you could take a look at the code that is doing this and point me in the right direction? We would be willing to pay for it. I’ve created a screencast of the issue and have included the aforementioned code below. Thanks for any help you can give!
Screencast: https://drive.google.com/file/d/1TEhCsUhxEIqOZ0Mq7rBO6FpbyA-glpyB/view?usp=sharing
Wcloner Code Snippet:
function process_bloqs_fields($entry, $old_entry)
{
// Get field group id
$fields = $this->get_fields($entry, 'bloqs');
// Process each bloqs field
foreach ($fields as $row)
{
$bloqs_query = ee()->db->select('*')
->from('blocks_block')
->where(array('entry_id'=> $old_entry->entry_id, 'field_id' => $row))
->get();
foreach ($bloqs_query->result() as $bloqs_row)
{
// Save original bloqs id
$bloq_id = $bloqs_row->id;
unset($bloqs_row->id);
$bloqs_row->entry_id = $entry->entry_id;
ee()->db->insert('blocks_block', $bloqs_row);
$new_bloqs_id = ee()->db->insert_id();
// Go through atoms for each bloq
$atoms_query = ee()->db->select('*')
->from('blocks_atom')
->where('block_id', $bloq_id)
->get();
foreach ($atoms_query->result() as $atoms_row)
{
unset($atoms_row->id);
$atoms_row->block_id = $new_bloqs_id;
ee()->db->insert('blocks_atom', $atoms_row);
$new_atom_id = ee()->db->insert_id();
// Check to see if it's a relationship field and update relationships as needed
$rel_query = ee()->db->select('type')
->from('blocks_atomdefinition')
->where('id', $atoms_row->atomdefinition_id)
->get();
if ($rel_query->row()->type == 'relationship')
{
ee()->db->update('relationships', array('grid_row_id' => $atoms_row->block_id), array('parent_id' => $entry->entry_id, 'grid_field_id' => $row, 'grid_col_id' => $atoms_row->atomdefinition_id, 'grid_row_id' => $bloq_id));
}
}
}
}
}
BoldMinded (Brian)
I don’t have time for additional freelance work right now, but this is what I have working in another project. You may need to remove the Publisher specific code. I have a heavily modified version of wCloner, so I’m not sure if this is a drag and drop replacement, you might have to fiddle with it a bit.
BoldMinded (Brian)
Sorry, code won’t fit in a comment. Here is the Gist. https://gist.github.com/litzinger/53db6b958a439a3c4df12eb360c238b9
Luke David
Thanks SO MUCH! I’ll give it a shot.
Luke David
I’ve got it working. Thanks for the boost!