Restoring deleted block packages

Permalink Browser Info Environment
Somehow one of my sites was a completely deleted off my server. (I'm not sure how, I hadn't been in that folder for months and the client says they didn't do it) I am now trying to restore the site from the files I have locally. The host does not have a valid backup so that isn't an option. Having never had this happen before, I never thought to backup the Designer Content packages after they were created.

Basically, here is where I stand, the database, theme and concrete core are all still intact. What I lost was the packages I installed. I obviously can get the packages I installed from the marketplace, but I have no local files of the Designer Content blocks I created, except some CSS.

All that being said, is it possible to recreate Designer Content blocks if I have all the data still in the database?

Type: Discussion
Status: New
drumrby
View Replies:
jordanlev replied on at Permalink Reply
jordanlev
Hi,
I'm really sorry that this happened to you. There is unfortunately no way to automatically recreate the blocks, but you could try examining the fields of the saved data, and try reconstructing the blocks from that. Basically, every field is named "field_[number]_[type]_[component]". For example, "field_2_textbox_text" means the 2nd field of the block was a "textbox" (and textboxes only have one "component", which is the text itself). Another example: "field_3_image_fID" is the third field in the block, and it's an Image field (and the "fID" in this case is the "file ID" component of the image -- there will probably also be a "field_3_image_alt" which is the alt text of that image).

Note that some numbers will be skipped, if some of the "fields" were of the "Static HTML" type (they take up a slot in the designer content dashboard page, but they don't have any data that is saved to the database so there is no field in the database schema for them).

All that being said... there is another problem which has nothing to do with Designer Content but rather the way C5 works in general: it might be difficult to figure out which block with which data goes on which page. Perhaps your database backup already has all that saved properly, in which case there won't be a problem. But you should probably test this assumption out with just one block first, before going through all the trouble of recreating all your Designer Content blocks only to find out that you don't know where to put them on what page of the site.

I hope you are able to fix this situation -- good luck!

-Jordan
drumrby replied on at Permalink Reply
drumrby
Thank you Jordan! You are helpful as always.

Other than the individual field information that you were talking about, do I need to know any sort of specific information to individual packages, like an ID number or something that might need to go in the controller file or somewhere like that? I haven't ventured into creating my own blocks just yet so I apologize if this is a novice question.
jordanlev replied on at Permalink Reply
jordanlev
You will need to give them the same block handle, which you should be able to extrapolate from the table name. The table names are "btDC[CamelCaseVersionOfHandle]". So they always start with "btDC" (which stands for "blocktype Designer Content"), then everything after that is the CamelCase version of the handle. The handle itself is *not* camelcase, so you need to "convert" by making every letter lowercase, and inserting an underscore before every capital letter (except the first one). For example: if the table name is "btDCEmployeeBio", then the handle would be "employee_bio" (without the quotes). If the table name is "btDCMyAwesomeBlock", then the handle is "my_awesome_block". If the table name is "btDCSomething", then the handle is just "something".

You'll want to extrapolate all of this from your database schema, then plug it all back into Designer Content on your new site. The block names and descriptions don't matter -- just the block handle (and the exact order of the fields). After you've recreated a block, examine the "db.xml" file in the block's folder and make sure it matches up with the field definition in your database backup. You'll probably have to try a few times before getting it right.

Finally, one more thing I forgot to mention: even if this winds up working, you still will need to recreate the front-end markup of the block (the HTML that surrounded the fields) -- there is absolutely no way to retrieve that without the original block files, so you'll need to recreate that work.
drumrby replied on at Permalink Reply
drumrby
Thanks again Jordan for your help! I will give it a try and let you know how it goes.

Also, on a side note, thank you for making such an awesome tool for Concrete5!

concrete5 Environment Information

Browser User-Agent String

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You have not specified a license for this support ticket. You must have a valid license assigned to a support ticket to request a refund.