Hello everybody,
I’m writing here to share a new package I recently developed which may be useful: Blocks Cloner (available on GitHub - open source with MIT license).
It’s a package that allows you to “copy” blocks between different websites.
It works with concrete5 v8.5 and ConcreteCMS v9.
I think this package can be useful for:
- people who want to copy contents from a website (an old one, a staging site, …) to another one (the new one, a production site, …)
- package developers who want to check if a new block type correctly supports exporting/importing blocks in CIF format (based on XML)
Here’s how it works:
Export
Once you install the package and you edit a page, click a block: you’ll see a new “Export as XML” menu item:
If you click that item, you’ll be able to view and copy the CIF that defines the block and its data:
You can also pick the block to be exported by clicking the following icon that you’ll see in the toolbar:
If you click that icon, you’ll see a panel where you can see the whole page structure and click the block you want to be exported:
Import
Once you have copied the CIF, you can “paste” it into a specific area by clicking the new “Import Block from XML” context menu item:
When you click that item, you’ll be presented a dialog where you can paste the CIF text, and optionally choose where the new block should be inserted (before another block that exists in the area):
When you click the “Analyze” button, the code checks if there are some errors (invalid XML, unknown block types, access denied for adding that block type to that area, …).
If the checks pass, you’ll be able to actually import the new button:
In order to pick the destination area, you can also click the following new button you’ll see in the toolbar:
If you click it, a panel will appear, allowing you to select the area where you want to paste the CIF of the new block:
Remarks
- this package is still in a rather early stage (I still have to take care of some stuff like handling missing images)
- this package requires that blocks correctly support importing and exporting data in CIF format: don’t blame me if a block developed by someone else doesn’t work as expected