|
| 1 | +--- |
| 2 | +title: Pattern Builder Importer |
| 3 | +--- |
| 4 | + |
| 5 | +## Pattern Builder Importer Drupal Module |
| 6 | + |
| 7 | +1. Why |
| 8 | + 1. With a library of patterns created in Pattern Builder, we need a method for creating each Drupal admin interface that allow users to enter the data needed for each template. |
| 9 | + 2. As a content admin, you may want to create a customizable content type(s) which include entity references to smaller content patterns, such as field collection bundles. These bundles will be built to match the defined components from the Styleguide. This would expose the ability to both create content and control the ordering, layout, and design from within the node editing interface, and would be fully revisionable. Additionally, editors would be able reference & include existing view blocks within the field groups. Editors could then apply data attributes such as layout and theme to these view blocks or field collections. |
| 10 | + |
| 11 | +2. What is it |
| 12 | + 1. TL;DR |
| 13 | + 1. It takes an external library (of JSON Schemas and Twig templates), and converts the schemas into fields in Drupal as paragraph bundles, and imports the twig templates and converts them to PHP to render the nodes. |
| 14 | + |
| 15 | + 2. Features |
| 16 | + 1. Includes support for multiple templates and schemas |
| 17 | + - You can list WebRH as the default library, then your own custom library |
| 18 | + - If templates have namespace collisions… |
| 19 | + 1. Check to see what twig.js does (does first or last win) |
| 20 | + |
| 21 | + 2. Automated Tests |
| 22 | + |
| 23 | +3. How |
| 24 | + 1. Tech Setup |
| 25 | + 1. Install and enable module |
| 26 | + 2. Set up the import paths in settings.php in admin config page |
| 27 | + - Go to admin/config/content/patternbuilder |
| 28 | + - Schema directories |
| 29 | + 1. sites/all/libraries/{webrh}/dist/library/schemas |
| 30 | + |
| 31 | + - Template directories |
| 32 | + 1. sites/all/libraries/{webrh}/dist/library/templates |
| 33 | + |
| 34 | + 3. Use Drush to run the pattern builder import command |
| 35 | + - If there are new patterns, first rsync webrh |
| 36 | + - SSL into sandbox |
| 37 | + - Run `drush pbi` |
| 38 | + |
| 39 | + 4. View the imported patterns now stored as paragraph bundles |
| 40 | + - Visit admin/structure/paragraphs |
| 41 | + |
| 42 | + 5. Manage Fields on the (new) content type, |
| 43 | + - Add a paragraphs field, choose which patterns you want to make available for content editors |
| 44 | + - Set widget to “Embedded Patterns” |
| 45 | + |
| 46 | + 6. Manage Display: Set the display format on the paragraph field to "Patternbuilder rendered items" |
| 47 | + 7. Other Notes: |
| 48 | + - Don’t forget to load the webrh.css via a pre-process function or the style module |
| 49 | + - Optional: Modify the content type node--[type].tpl.php as needed to remove other regions etc |
| 50 | + - To use the test pattern, enabled “Red Hat webrh test” on the modules page: /admin/modules?filter=webrh_test&enabled=1&disabled=1&required=1&unavailable=1 -- it will take a while to import so you have to wait for the page to be done refreshing |
| 51 | + |
| 52 | + |
| 53 | + |
| 54 | + 1. Drush Commands |
| 55 | + 1. Imports patterns from defined library |
| 56 | + - drush pbi : Import all schemas. |
| 57 | + - drush pbi --all : Force the import of all schemas even if specific schemas are defined. |
| 58 | + - drush pbi band card : Import only the "band" and "card" schemas. |
| 59 | + - drush pbi --type=layout : Import only the schemas for the "layout" pattern type. |
| 60 | + - drush pbi -image_box |
| 61 | + |
| 62 | + 2. Remove imported patterns from Drupal |
| 63 | + - drush pbi-remove : Nothing is removed. This safeguards against accidental commands. |
| 64 | + - drush pbi-remove --all : Removes all schemas. |
| 65 | + - drush pbi-remove band card : Removes only the "band" and "card" schemas. |
| 66 | + - drush pbi-remove --type=layout : Removes only the schemas for the "layout" pattern type. |
| 67 | + |
| 68 | +1. Where |
| 69 | + 1. [https://www.drupal.org/project/patternbuilder](https://www.drupal.org/project/patternbuilder) |
| 70 | + 2. [https://web-dev-gitlab03.devlab.redhat.com/it-marketing/webdrupal](https://web-dev-gitlab03.devlab.redhat.com/it-marketing/webdrupal) |
| 71 | + |
| 72 | +2. Supported Extensions |
| 73 | + |
| 74 | +The following are optional Drupal modules that are supported natively by the Pattern Builder Importer. |
| 75 | + |
| 76 | +1. Media ([https://www.drupal.org/project/media](https://www.drupal.org/project/media)) |
| 77 | + 1. Supports: file, image, audio, video |
| 78 | + 2. Schema usage: "entity": "file|image|audio|video" |
| 79 | + |
| 80 | +2. Media Internet - Submodule of Media ([https://www.drupal.org/project/media](https://www.drupal.org/project/media)) |
| 81 | + 1. Supports: internet based files |
| 82 | + 2. Schema usage: "entity": "file|image|audio|video" |
| 83 | + |
| 84 | +3. Media YouTube ([https://www.drupal.org/project/media_youtube](https://www.drupal.org/project/media_youtube)) |
| 85 | + 1. Supports: YouTube videos |
| 86 | + 2. Schema usage: "entity": "video" |
| 87 | + |
| 88 | +4. Link ([https://www.drupal.org/project/link](https://www.drupal.org/project/link)) |
| 89 | + 1. Supports: link fields |
| 90 | + 2. Schema usage: "entity": "link" |
| 91 | + |
| 92 | +5. Field Collection ([https://www.drupal.org/project/field_collection](https://www.drupal.org/project/field_collection)) |
| 93 | + 1. Supports: array of objects imported as a field collection. |
| 94 | + 2. Schema usage: array<object> |
| 95 | + |
| 96 | +6. Field Collection Fieldset ([https://www.drupal.org/project/field_collection_fieldset](https://www.drupal.org/project/field_collection_fieldset)) |
| 97 | + 1. Supports: collapsible array of objects imported to a field collection. |
| 98 | + 2. Schema usage: options.collapsed=true, options.disable_collapse=true |
| 99 | + |
| 100 | +7. Field Multiple Extended ([https://www.drupal.org/project/field_multiple_extended](https://www.drupal.org/project/field_multiple_extended)) |
| 101 | + 1. Supports: Set minimum and maximum items on a property. |
| 102 | + 2. Schema usage: minItems: 2, maxItems: 10 |
| 103 | + |
| 104 | +1. Future Plans |
| 105 | + 1. Use standard Drupal 8 rendering engine |
| 106 | + 2. CMI (config mgmt), use schemas to manipulate YML files |
0 commit comments