1

I am trying to add a seeded:true flag to dummy entries seeded during development, so I can automatically weed (delete) them later when I'm ready to save the actual live content.

I know I can create a field and associate with entry type, but that would not be not ideal as this is purely development metadata that should not be exposed to CP users or loaded when editing the entry, not even as a hidden field.

Is this type of schemaless behavior possible in Craft? If not I suppose I can add a nullable metadata column to the entries table and save as JSON, but would prefer to avoid a major change for a relatively simple problem.

2

I'm not sure there's a simple way to add metadata to entries without messing with the database or writing your own workaround. But if you only care about the value not being visible in the CP, you can use the Incognito Field plugin. It's just a regular plain text field that you can set to readonly or hide completely.

I solved a similar problem for a migration of an old Drupal site this way. Added a hidden field to keep track of the old node ID, this way we could map relationship fields easily in our migration script. The field will even stick around after the site is live, allowing us to redirect direct node links (node/123456) to the newly created entry.

Sidenote: If you develop in a separate environment from the staging/live site, which you should, you don't have this problem. You can fill your database with dummy content all you want without it affecting the staging site, and you don't have to get rid of it when the site goes live.

1
  • 1
    Thanks. I develop locally of course, but sometimes you want to add the actual content to your local DB and then copy it to production on initial release. E.g if I am developing a blog, I would first auto seed some dummy posts - which will allow me to focus on design and structure rather than content - do all the front-end work, and then, when I'm ready to deploy, delete them and replace with actual content, to avoid an empty blog on initial release.
    – Matanya
    Nov 26 '21 at 19:21

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.