2

A site I manage has thousands of entries across dozens of channels where the main textual content is stored in Wygwam fields. I'd like to convert (or perhaps duplicate and convert) those fields over to either Krea's Content Elements, or Bryan Burgers' Blocks, while retaining existing content in a Wygwam element/block inside either of those two add-ons' fields.

Is this possible, and if so, how would I do it?

2

I had a similar issue in the past moving a large amount of content from one field to another in a different channel. I used MySQL to achieve this, unfortunately I'm not too good with MySQL and it was some time ago and I can't find the link I used the query from but hopefully this points you in the right direction.

What I did was;

  • Most importantly make sure you have a backup!
  • create the new field
  • go to the Database, find out field ids etc (you will need the field_id and field_ft from what I remember
  • use a mysql command to copy the data of the WYGWAM field to your new field

hope this helps.

| improve this answer | |
  • Yeah, that's the obvious method. I guess the follow-up question is how either of those two add-ons stores it's data in the DB; they're both so complex that I have a hard time imagining that it's a simple "copy from row A to row B" process... – Sandwich Feb 23 '15 at 13:17
2

There is no officially sanctioned way to do this for Blocks. And, as far as I'm aware, there is no third-party add-on that will make this easy.

Like sheferd said, you're going to want to make a backup, find the field ids in the database, etc.

  1. In Blocks, create a new block type by going to Add-Ons → Modules → Blocks. Create a block type with a single Wygwam field in it.

  2. This block definition will be stored in the database in exp_blocks_blockdefinition, and its Wygwam field will be in exp_blocks_atomdefinition. You'll want to grab both of those IDs.

    Here's where you might want to drop into a custom PHP script, though it might be possible to do with just SQL.

  3. Create a block by adding to exp_blocks_block. blockdefinition_id is what you looked in step #2. site_id and entry_id mean what you think they mean. field_id is the ExpressionEngine field that this Block will belong to (retrieved from Admin → Channel Administration → Channel Fields). order will probably be 1, which means it is the first block for that field. When you insert into this table, take note of the ID that is autocreated; you'll need it for when you add your content as an atom.

  4. Create an atom by adding to exp_blocks_atom. block_id is the ID you got when you created a row in step #3. atomdefinition_id is what you looked up in step #2. data is your Wygwam data, retrieved from the exp_channel_data table.

If you run into trouble, you can fill out Blocks' support form and I'll be happy to help.

| improve this answer | |
  • Thanks for the pretty thorough answer! I wish the site in question was already running Blocks, but we started implementing CE before Blocks came out, so if I go the Blocks route, we'd have two similar add-ons doing the same jobs in different channels. >.< I'll have to think this over... I don't suppose there's a CE -> Blocks conversion script anywhere? :-/ – Sandwich Feb 25 '15 at 12:22
  • Sorry, I can't help you at all there. I know zero about how CE stores its data. – Bryan Feb 25 '15 at 12:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.