Various Scenarios of using pattern builder module
Add a Pattern Field to a Content Type
- Create a new content type or use an existing one.
- Add a paragraphs field with patterns enabled.
- Widget: "Embedded Patterns" or "Embedded Patterns with Previewer" (requires patternbuilder_previewer module).
- Limit the pattern selection by type ("Pattern", "Components"). These need to be defined in hook_patternbuilder_pattern_types().
- Any non-pattern paragraph needs to be explicitly selected in the list of "Allowed paragraph bundles"
- Display Formatter: "Patternbuilder rendered items"
- Select display mode used to render the embed paragraphs. Defaults to "Full". For Patterns, the formatted values of the paragraph field is sent to the TWIG templates for display.
- Widget: "Embedded Patterns" or "Embedded Patterns with Previewer" (requires patternbuilder_previewer module).
- Create content with Patterns!
Choose a method
-
The whole kit AND kaboodle! (recommended) Use pattern builder importer to pull in your patterns and schemas from your component library
- Build a content type with a Pattern field (see above).
- Configure the directories for the JSON schemas and TWIG templates at "admin/config/content/patternbuilder"
- Enable the patternbuilder_importer module.
- Import the Pattern Schemas to Paragraph bundles:
- From the command line, run "drush pbi".
- (TODO) From the UI: Pending development.
-
Hybrid: Map existing Drupal fields to Schema properties
- Allows for developers to map data (even from external sources) to the json/twig data.
- Good for existing content types.
- Not good for complex field setups since hand mapping takes time and is error prone.
- How:
- Override the node view of a given content type.
- Use the existing Drupal fields to build the render object using the PatternBuilder Library. For more detail, see section "PHP Library" > "Rendering a Schema".
- Set the node view content as the rendered object.
-
(TODO) Component library only, No importer
- Build a content type with a Pattern field (see above).
- Configure the directories for the JSON schemas and TWIG templates at "admin/config/content/patternbuilder"
- Create a paragraph bundle.
- (TODO: Pending development) Associate the paragraph bundle with a JSON Schema.
- Add a field to the paragraph bundle.
- Configure the section "Pattern Builder".
- Required: Set the "Property name" of the JSON Schema property that maps to this field.
Other things to note
- Your Drupal theme should (only) be responsible for the chrome of the site (header & footer)