项目作者: statamic

项目描述 :
Convert Replicator fields to Bard fields
高级语言: PHP
项目地址: git://github.com/statamic/bardify.git
创建时间: 2018-01-11T21:14:24Z
项目社区:https://github.com/statamic/bardify

开源协议:

下载


Overview

Bard fields are just like Replicator fields, except that the “text” blocks are implied and saved as text in your content.

For example you may have a Replicator field in your fieldset where you use your “text” set like this:

  1. fields:
  2. story:
  3. type: replicator
  4. sets:
  5. content: # The "text" set. It's the one with just a single text based field.
  6. fields:
  7. html:
  8. type: redactor
  9. quote:
  10. fields:
  11. quote:
  12. type: text
  13. cite:
  14. type: text

and your data would be saved like this:

  1. story:
  2. -
  3. type: text
  4. html: "<p>This is my story</p>"
  5. -
  6. type: quote
  7. quote: Oh Hai Mark
  8. cite: Tommy Wiseau

To change to Bard, you’d need to replace your content/html set to text/text.

  1. story:
  2. -
  3. type: text
  4. text: "<p>This is my story</p>"
  5. -
  6. type: quote
  7. quote: Oh Hai Mark
  8. cite: Tommy Wiseau

Simple enough, but tedious to do it for all your entries.

If you happened to already call your text set text with a field named text - you’re in luck and don’t need to change anything.

Usage

Note: This modifies your data, so consider making a backup first.

Another Note: This doesn’t support multiple locales yet.

Download this repo and place it in site/addons/Bardify and run this command:

  1. php please bardify

It will automate the following:

  • Go through any relevant content files and change the types/fields.
  • Remove the “text” set from the Replicator field.
  • Change type: replicator to type: bard. (Wow!)
  • If you were using a markdown fieldtype for the text field, it will add markdown: true to the Bard field.

Converting content fields to Bard

You may also convert your content field (the text below your YAML front-matter) into a Bard field by running the following command:

  1. php please bardify:content

It will automate the following:

  • Go through any relevant content files and replace the content text with the field name of your choice.
  • If you were using a markdown fieldtype, it will add markdown: true to the Bard field.