This is a proof of concept to continue our conversation on document management in Drupal 8.

Creating a Document in Drupal 7:

  • Create a node of type Document. This node type is similar to the site page, but contains four additional taxonomy fields and publication date/updated date fields.
  • After filling out the node fields and uploading a file(s), I have a web page that displays documents with a unique URL, metadata, and can be included in a site menu.

Result:

  • A node, viewable as a web page with customizable URL displaying your file(s). It can also be displayed within a view.

Creating a Document in Drupal 8:

Create a node of type Site Page. Fill out typical site page related fields. The file upload field has been replaced with a Media Entity Reference field. To attach your file, select Add Media under the field labeled Associated Files.

From there you either select an existing media item, or:

  • Create a Media Entity of type Document. This media entity contains the following fields:
  1. Name: The name of the media entity, used for display on the media browser.
  2. Document: File upload field. Allows the upload of a single file.
  3. Generic Document Category: Taxonomy field for categorization.
  4. Division/Office: Taxonomy field for categorization.
  5. Document Collection: Taxonomy field for categorization.
  6. Document Terms: Taxonomy field for categorization.
  7. First Published: Date Field.
  8. Last Updated: Date Field.

Save your new Media Entity and attach.

Result:

  • A web page with customizable URL displaying your file(s).
  • A reusable Document Media Entity that can be:
  1. attached to nodes via media entity reference fields  
  2. displayed within views
  3. May not be viewed publicly at a standalone URL – only in attachment to nodes or displays in views.  

Disadvantages of the Drupal 7 approach:

  • In Drupal 7, you could attach the same file to multiple nodes via IMCE. Because the reference is directly to a filename, the only way to update the file on all nodes is to overwrite the file.

Advantages of the Drupal 8 approach:

  • In Drupal 8, you can reference media entities in both media entity reference field AND in the wysiwyg editor. References to media in the wysiwyg will automatically update when the media entity is updated.

Notes:

This approach does not allow access to standalone media entites. This means that document entities can only be rendered via nodes or views. Georgia does not allow access to standalone media entities: https://sbwc.georgia.gov/document/publication/wc-fraud-poster-spanish

We need to determine how files will be placed in the file system when uploaded to a media entity – will users have access to the file system? We could automatically place uploaded files in directories based upon date of upload. Users could instead focus on media entity management instead of file system management.

We need to determine if the Document media entity type is satisfactory for all non image-related media. We could create additional media entity types.

We need to determine the URL pattern for media entity download links.