Home>Support>Copy a row to another page

Copy a row to another page

I searched the forum for posts about the ability to copy a row, with all its contents and links and paste into another page. The only things that I could find were some old posts containing acknowledgements that this would be a great feature which might be offered down the road.

Well, we are down the road. Is this feature available now? If not, do you have any idea when it might be available?

This feature would be a huge time saver for me. I have one row that appears on nearly every page which contains several graphics that link to other pages on my site. I would like to replace these graphics with new ones but doing so would require me to manually update nearly 100 pages. Being able to cut and paste would shorten days of work to less than an hour.

Thanks for your consideration.

This is our free support forum. Replies can take several days. If you need fast email support, please purchase a SiteOrigin Premium license.

  1. 9 years, 6 months ago Greg Priday
    Hi, I Work Here

    Hi Bob,

    Unfortunately this feature isn’t available yet. I did experiment with this feature in my development version and there were a few issues getting copy paste to work. Browser security makes performing copy-paste operations quite difficult, so it’s only really possible using some Flash hacks, which I don’t really want to do.

    We will investigate some possible elegant solutions in a future update, but we’ll only release this feature when it’s good and ready. A half-hearted implementation of copy-paste would hurt more than help :)

    I’ve marked this thread as a feature request so it can weigh in for this thread. We use these threads to plan future updates.

  2. 9 years, 6 months ago Bob Van Epps

    Thanks for the reply. I am glad that you are considering the addition of this feature.

  3. 9 years, 6 months ago Jim Benson

    I’d be very interested in this feature as well. Thanks!

  4. 9 years, 2 months ago Ka Fong

    Please add this function ASAP
    its really big demand for me :'( :'( :'(
    (Thanks for your great plguin anyway…its really helpful at all)

  5. 9 years, 2 months ago Greg Priday
    Hi, I Work Here

    I had a little bit a look at this feature and unfortunately it was a little more difficult to implement than I originally thought. Javascript doesn’t give you native copy paste functionality so it needs all kinds of Flash libraries – which I really didn’t want to add.

    We’ll look at another solution though.

  6. 8 years, 10 months ago Lucas Balzer

    Hi! I’m a huge fan of page builder and I’m also looking for the ability to copy a row from one page/post to another.

    It sounds like your approach for this process is to copy _something_ from a post edit screen to the clipboard, and then paste that _something_ into another post edit screen. You’re hesitant to implement this because a browser-based copy/paste situation requires Flash dependencies.

    If the user’s clipboard is the way you’d approach this, I just stumbled across this project, which claims to remove the Flash dependencies from the ability to copy content to a user’s clipboard from a browser: http://zenorocha.github.io/clipboard.js/

    However, I feel that this approach is mired in the traditional concept of copy-switch-paste, rather than programmatic, direct access to the target item.

    In the context of copying a row from one post to another in WordPress, there’s no reason to put _anything_ into the user’s clipboard. We have (presumably as an author, and definitely as an editor or admin) universal access to all post content at all times via $wpdb.

    Here is my pseudocode suggestion for copying a row from one post to another without any JS clipboard dependencies at all:

    It seems all content for PageBuilder rows is saved in the post_meta table as part of the serialized array that is in all the post_meta fields in post_content, so I suggest adding the row directly to the post_meta field of the target post via $wpdb

    (Note: $ prefix indicates a variable)

    * (NEW MENU ITEM UNDER WRENCH ICON ON EACH ROW) Wrench Icon -> Copy row to another page/post
    * Popup window showing all pages/posts. User selects target page/post. This populates the variable $targetPostID
    * Grab current post’s post_meta information, unserialize it into a JS array $sourcePostMeta
    * You now have array access to
    ** The grid layout parameters of the row we want to copy, via $sourcePostMeta[‘grids’][$rowNumberSelectedToCopy]
    ** The settings and content of the widgets in the row we want to copy, via $sourcePostMeta[‘widgets’][$rowNumberSelectedToCopy]
    * Using admin-ajax.php, you can now perform the following SQL update via the $wpdb:
    (This assumes the target page is already a Page Builder page, which it should be anyway, if we’re copying a row into it)
    ** $wpdb->get ( post_meta from $targetPostID)
    ** Unserialize post_meta into $targetPostMeta
    ** Append $sourcePostMeta[‘widgets’][$rowNumberSelectedToCopy] to $targetPostMeta[‘widgets’][$rowNumberSelectedToCopy]
    ** Append $sourcePostMeta[‘grids’][$rowNumberSelectedToCopy] to $targetPostMeta[‘grids’][$rowNumberSelectedToCopy]
    ** Serialize $targetPostMeta to $serializedTargetPostMeta
    ** $wpdb->update( post_meta SET meta_value=$serializedTargetPostMeta WHERE post_id=$targetPostID)
    ** Optionally, you could fire the post_saved action for $targetPostID, so that the post_meta is processed and dumped into post_content. This way, you don’t have to edit and resave the target post before the new row will render on the WP frontend.

    I hope this helps to overcome the technical limitations of a traditional copy/paste structure, and is useful to build a conceptual process to copy a row to another post using methods other than a clipboard.

    Thanks again for your awesome tool, and I hope this post can help flesh out a valuable feature.

    • 8 years, 10 months ago Greg Priday
      Hi, I Work Here

      Hi Lucas

      Thanks for the very awesome feedback. The only reason I’d prefer a clipboard based approach is that it might allow a user to copy paste between WordPress installations, without a shared $wpdb. That clipboard.js is an amazing find. I didn’t know about that before.

      I’ll take another look at implementing copy paste functionality using clipboard.js. If I can’t get that right, I’ll take a deeper look at your proposed implementation. It looks very interesting.

  7. 8 years, 10 months ago Lucas Balzer

    Glad to have turned you on to clipboard.js! You’re right that inserting into the Page Builder post_meta record would limit the ability to copy between installs, and you’re also right that that is an important feature of a Copy Row feature. I’ve done some more thinking about how to solve that problem.

    This also led me to realize that a useful feature in a row copy scenario would be the ability to multi-select rows to copy, rather than having to choose between one-row-at-a-time and the-whole-page.

    A ‘Copy Rows’ toolbar button would add a checkbox next to each row. Once one checkbox is ticked, the ‘Copy Rows’ button would activate dropdown available next to it with the options of Export to File, as well as a list of all pages/posts that are Page Builder pages. The Export to File would download a JSON file similar to your current export and would likely contain an initial comment indicating that this is a ROWS file, rather than a PAGE file.

    SOLVING THE PROBLEM BETWEEN INSTALLS
    Divergent UI processes are created if copying a row between installations uses the clipboard for a copy/paste process, while copying a page between installations uses a file download/upload process.

    Copying a row between installations is (to some extent) already supported by the existing Import tool. Extending the Import tool to differentiate a PAGE file from a ROW file would allow the user to export either a row(s) or a whole page structure for moving between installs and the import tool would simply execute the correct import method, depending on the source file type. Now we have a single path to take whether we’re copying rows or duplicating a page.

    I realize that importing a page layout currently overwrites the existing Page Builder content, but if we checked what kind of import is happening, the ROW import file could be handled differently than the PAGE file. The ROW file could be parsed and inserted to the gird without overwriting the existing grid by reusing the row-insert method (theoretically) used by the copy-a-row-within-an-install process:

    $target_post_ID = $post->ID;
    $content = array(widget_content_imported_from_file);
    $grids = array(grid_definitions_imported_from_file);
    $page_builder_page.insert_row_to_post_meta( $target_post_ID, array( $content, $grids ) ) );
    

    SOLVING THE PROBLEM IN A SINGLE INSTALL
    Once the between-installs row copy process is implemented via direct DB manipulation, it’s trivial to implement that solution within an install. Rather than the source data coming from a file and the target post ID being the current page/post, it would look similar to this:

    $target_post_ID = $selectedTargetID;
    $content = array(widget_content_from_identified_rows);
    $grids = array(grid_definitions_from_identified_rows);
    $page_builder_page.insert_row_to_post_meta( $target_post_ID, array( $content, $grids ) ) );
    

    Additionally, if the “Select your target pages/posts” were a multi-select box, you could do the following:

    $target_post_ID = $selectedTargetIDs;
    $content = array(widget_content_from_identified_rows);
    $grids = array(grid_definitions_from_identified_rows);
    
    foreach ($selectedTargetIDs as $targetID)
      $page_builder_page.insert_row_to_post_meta( $targetID, array( $content, $grids ) ) );
    

    I hope this reasoning encourages you to use the post_meta concept, rather than the clipboard concept. While it seems cool to be able to use the browser clipboard, I feel that the post_meta concept allows for the most flexibility in choosing multiple rows, copying to multiple destinations, exporting across installs, and minimizing the number of UI processes the user has to remember.

    Thanks for the discussion on this one!

  8. 8 years, 8 months ago Hugo Huang

    I really need that function……………………………………………………………………………………..I love siteorigin pb and I dont want to switch to another pb…………………………………….

  9. 8 years, 7 months ago Lucas Tolle

    While the appeal does not arrive, you can install Custome widget plugin.

    Then go to Settings and enable the posttype to work with the Page Builder.
    Ready. Just create your block and call them on any page you want.

    I hope this helps

    Lucas Tolle

  10. 8 years, 4 months ago Sergi Gambin

    I just write to give total support to the development of this feature, this would be amazing to have it! Will try what Lucas Tolle propose here meanwhile.

  11. 8 years, 3 months ago Erica Dyson

    Yes please! We love page builder!

  12. 8 years, 3 months ago Alex S
    Hi, I Work Here

    Hi Bob,

    It should be noted that you can technically do something like this now. Create a layout builder widget, click the prebuilt layout button in the page builder toolbar and clone the page that has the widget you wish to add to this page. This will allow you to copy over rows / widgets but the obvious downside being that it copies everything. It’s not much of a downside when you consider it’ll allow you to copy another row to another page via this method.

Replies on this thread are closed. Please create a new thread if you have a question, or purchase a SiteOrigin Premium license if you need one-on-one email support.

Get The Most Out of SiteOrigin with SiteOrigin Premium

Find Out More