Duplicating records?

16 posts by 7 authors in: Forums > CMS Builder
Last Post: December 20, 2011   (RSS)

By blukabm - August 19, 2008

I am curious if there is currently a way to duplicate a record. That way I could modify the copied record instead of creating a new one and re-entering data that won't change much.

Thanks!

Re: [Dave] Duplicating records?

By blukabm - August 20, 2008

Is that something that could be added through the custom programming option? If so, we may look into that.

Thanks!

Re: [blukabm] Duplicating records?

By Dave - August 20, 2008

Hi blukabm,

It can (as we're discussing over email) - another option might be to try and find a bookmarklet tool that would let you save the form data and re-output it.

I did a google search for "copy form values bookmarklet"
http://www.google.com/search?q=copy+form+values+bookmarklet

and found this site:
http://www.benjaminkeen.com/software/bookmarklet_generator/

I don't know if that will do exactly what you need or not but I thought it might be worth a look.

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Duplicating records?

By Dave - August 21, 2008 - edited: March 18, 2010

Here's an (unsupported) hack I wrote up to add a "Save as Copy" button to the bottom left of the edit page.

It doesn't support uploads or all the field types but worked for this case. I'm posting in here in case it turns out to be useful for someone else as well.

- Create a backup copy of /lib/menus/default/edit.php
- Open /lib/menus/default/edit.php
- Search for showWysiwygGeneratorCode
- Add the code in red (about 15 lines above showWysiwygGeneratorCode)

<table border="0" cellspacing="0" cellpadding="0" width="690">
<tr>
<td>
<input type="submit" name="action=save" value="<?php _e('Save as Copy') ?>"
onclick="document.getElementById('num').value=''; document.getElementById('preSaveTempId').value='1234567890abc'"
class="inputButton" />
</td>

<td align="right">
<input type="submit" name="action=save" value="<?php _e('Save') ?>" class="inputButton" />
<input type="button" name="cancel" value="<?php _e('Cancel') ?>" class="inputButton"
onclick="window.location='?menu=<?php print urlencode($menu) ?>'" />
</td>
</tr>
</table>
</form>

<?php showWysiwygGeneratorCode() ?>


Update: This version works for 2.00+ - search for _action=save

<div style="float:right">

<input type="submit"
name="action=save"
value="<?php et('Save As Copy') ?>"
onclick="document.getElementById('num').value=''; document.getElementById('preSaveTempId').value='1234567890abc'"
class="button" />


<input class="button" type="submit" name="_action=save" value="<?php et('Save') ?>" />
<input class="button" type="button" name="cancel" value="<?php et('Cancel') ?>" onclick="window.location='?menu=<?php print urlencode($menu) ?>'" />
</div>

Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Duplicating records?

Talk about perfect timing! I just had a client who asked for this capability so I tried this and it works great!

Thanks Dave!

Kevin

Re: [kevbarker] Duplicating records?

By sublmnl - February 21, 2011 - edited: February 21, 2011

<div style="float:right">
<input type="submit"
name="action=save"
value="<?php et('Save As Copy') ?>"
onclick="document.getElementById('num').value=''; document.getElementById('preSaveTempId').value='1234567890abc'"
class="button" />

<?php
$buttonsRight = '';
$buttonsRight .= "<input class='button' type='submit' name='_action=save' value='" .t('Save'). "' />\n";
if ($previewUrl) {
$buttonsRight .= "<input class='button' type='button' name='preview' value='" .t('Preview'). "' onclick=\"editPreview();\" />\n";
}
$buttonsRight .= "<input class='button' type='button' name='cancel' value='" .t('Cancel'). "' onclick=\"editCancel();\" />\n";
$buttonsRight = applyFilters('edit_buttonsRight', $buttonsRight, $tableName, $GLOBALS['RECORD']);
echo $buttonsRight;
?>
</div>


This kind of works.
Perhaps its the newer version of CMSB. I noticed that your code is a little different than the above which is what I have.
I have to make the image upload field not required in order to make a copy.
Dave can you update this?

THanks

Re: [sublmnl] Duplicating records?

By Jason - February 22, 2011

Hi,

We have a user submitted plugin that creates the "Save & Copy" button and functionality for you:

http://www.interactivetools.com/add-ons/detail.php?Save-Copy-Button-1030

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Duplicating records?

Thanks Jason, and that looks familiar...
And I remember why I couldn't use it.
Until I found this post today.



thanks!

Re: [sublmnl] Duplicating records?

Would be great is this also added a "Duplicate" link in the list view, next to View | Modify | Erase

:)