SOP Creating Content Types - NCIOCPL/cgov-digital-platform GitHub Wiki

  1. Follow the instructions for adding local fields

    • UNLESS otherwise noted, there should be at least a field_image_promotional in the list. If not, then ask REQ team.
  2. All content types should have the following Entity View Displays:

    • Full -- This is for the full page. Add those fields that will be displayed on the entire page.
    • Featured Card - This is for a feature card it should have all of the fields (incl. images) that will be displayed on the items. An example list is below, but your content type may have more structured data requiring additional/different fields:
      • Promotional Image
        • Rendered entity, rendered as Image Crop: Featured
      • Article Image
        • Rendered entity, rendered as Image Crop: Featured
      • Card Title
      • Short Title
      • Feature Card Description
    • Featured Card Image - This is for a feature card when it is used on a home/landing page. It is just for rendering the image within special templates:
      • Promotional Image
        • Rendered entity, rendered as Image Crop: Featured
      • Article Image
        • Rendered entity, rendered as Image Crop: Featured
    • Thumbnail Card - This is for a thumbnail cards it should have all of the fields (incl. images) that will be displayed on the items. An example list is below, but your content type may have more structured data requiring additional/different fields:
      • Promotional Image
        • Rendered entity, rendered as Image Crop: Thumbnail
      • Article Image
        • Rendered entity, rendered as Image Crop: Thumbnail
      • Card Title
      • Short Title
      • Listing Description
      • Meta Description
    • Thumbnail Card Image - This is for a thumbnail card when it is used on a home/landing page. It is just for rendering the image within special templates:
      • Promotional Image
        • Rendered entity, rendered as Image Crop: Thumbnail
      • Article Image
        • Rendered entity, rendered as Image Crop: Thumbnail

    TO BE CONTINUED... (Listings, Teaser?, RSS??)

  3. UNLESS EXPLICITLY noted, no labels should display. Never. Never ever ever. We usually control these on the front-end through templates, and usually because they do not match our front-end display label. Other times, well, they look pretty stupid.

How To Create A Content Type

  1. Bring up your Docker stack, install Drupal, etc.
  2. Export the baseline configuration drupal config:export --directory="../files-private/baseline-config" --remove-uuid --remove-config-hash
  3. Create the content type in the UI
  4. Delete the default Body field.
  5. Export the new configuration drupal config:export --directory="../files-private/feature-config" --remove-uuid --remove-config-hash
  6. Compare baseline-config and feature-config directories. These are the configuration changes you need for the new content type.
  7. Create the module for the new content type (all content types are modules)
    1. Create the new module directory (e.g. cgov_cancer_center) in docroot/profiles/custom/cgov_site/modules/custom/
    2. In this directory
      • Create the module's info file (e.g. cgov_cancer_center.info.yml). This may be created by copying from a smilar content type.
      • If needed, create the module install hook (e.g. cgov_cancer_center.install).
      • (Optional) Create the module file (e.g. cgov_cancer_center.module).
      • Create a README.md explaining the module's high-level purpose and listing any dependencies.
    3. Place the module's configuration files (most of the files from the comparison step) in the config/install directory under the module directory.
  8. Add the content type’s machine name to the site’s module install list. (e.g. docroot/profiles/custom/cgov_site/cgov_site.info.yml)
  9. Reinstall Drupal.
    1. docker-compose exec web bash
    2. blt drupal:install --no-interaction
    3. blt drupal:toggle:modules
  10. Export the configuration again: drupal config:export --directory="../files-private/test-config" --remove-uuid --remove-config-hash
  11. Compare the test-config directory to the feature-config directory to verify that all expected changes are present.