SOP Creating Content Types - NCIOCPL/cgov-digital-platform GitHub Wiki
-
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.
-
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
- Rendered entity, rendered as
- Article Image
- Rendered entity, rendered as
Image Crop: Featured
- Rendered entity, rendered as
- Card Title
- Short Title
- Feature Card Description
- Promotional Image
- 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
- Rendered entity, rendered as
- Article Image
- Rendered entity, rendered as
Image Crop: Featured
- Rendered entity, rendered as
- Promotional Image
- 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
- Rendered entity, rendered as
- Article Image
- Rendered entity, rendered as
Image Crop: Thumbnail
- Rendered entity, rendered as
- Card Title
- Short Title
- Listing Description
- Meta Description
- Promotional Image
- 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
- Rendered entity, rendered as
- Article Image
- Rendered entity, rendered as
Image Crop: Thumbnail
- Rendered entity, rendered as
- Promotional Image
TO BE CONTINUED... (Listings, Teaser?, RSS??)
-
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
- Bring up your Docker stack, install Drupal, etc.
- Export the baseline configuration
drupal config:export --directory="../files-private/baseline-config" --remove-uuid --remove-config-hash
- Create the content type in the UI
- Delete the default
Body
field. - Export the new configuration
drupal config:export --directory="../files-private/feature-config" --remove-uuid --remove-config-hash
- Compare
baseline-config
andfeature-config
directories. These are the configuration changes you need for the new content type. - Create the module for the new content type (all content types are modules)
- Create the new module directory (e.g. cgov_cancer_center) in
docroot/profiles/custom/cgov_site/modules/custom/
- 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.
- Create the module's info file (e.g.
- Place the module's configuration files (most of the files from the comparison step) in the
config/install
directory under the module directory.
- Create the new module directory (e.g. cgov_cancer_center) in
- 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
) - Reinstall Drupal.
docker-compose exec web bash
blt drupal:install --no-interaction
blt drupal:toggle:modules
- Export the configuration again:
drupal config:export --directory="../files-private/test-config" --remove-uuid --remove-config-hash
- Compare the
test-config
directory to thefeature-config
directory to verify that all expected changes are present.