9

Starting on a second site which is an almost like for like copy of the first, except it has different content. I cant use locales to manage it because there may be the possibility of multiple languages on the second site.

I have dozens of field & entry types I want to transfer over to the second site. Is there an automated way of deleting all the content?

10

You could also delete all rows in your craft_elements table, which have type set to Entry (or whatever ElementType you want to delete).

  • 2
    This is a great answer. Deleting an element from the craft_elements table will properly cascade and automatically delete any related rows in other tables. – Lindsey D Jul 18 '14 at 17:59
  • How does this cascade? Is this a MySQL feature I don't know about? Thanks. – JamesNZ Jun 26 '16 at 23:23
  • Evidently it must be. I deleted all "Entry" rows from craft_elements and sure enough it emptied out all other relevant tables. Thanks for the suggestion. I'd love to know how that works if anyone knows? – JamesNZ Jun 26 '16 at 23:32
2

I figured it out somewhat by using the Import plugin, by Bob Olde Hampsink, exporting all my slugs to a csv, then using the delete functionality of the plugin to remove all entries with a slug found in the csv. Worked perfectly!

0

As far as I know, you can only do that by deleting and recreating a section.

0

On a related task, if you want to just empty out a section or type, delete queries in the entries table matching on sectionId or typeId fields. This also cascades. Then you can keep your other sections, especially singles, which otherwise force you to delete and recreate the section to restore the single type entry.

EDIT: After doing this and batch importing data, I noticed the slugs were generated as duplicates (added integer on the end). Sure enough, elements_i18n wasn't cleared out like entries and elements tables. So you'll have to change the query to delete rows from both tables or use the first method above and somehow filter for the sectionId you want.

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.