Description and Purpose
Managing of document files in Drupal 10 has been consolidated around the Document Entity system. Entities are similar to what "content" is, like the standard basic pages. For documents, this is essentially a wrapper for files so they can be managed easier and provide additional data about them. Without these, they are essentially just files in a folder with no way to work with them, such as including them in the site search. Depending on the history of your site, you may already be partially utilizing this system. We have added additional functionality to bridge the gap between the entity system and working with files directly using the IMCE dashboard. This means that:
- Every file has an associated document entity. These have been generated automatically if one did not exist.
- When a document entity is deleted, it deletes the file associated with it off the file system.
- New functionality added directly in the document editor to replace a file with the existing file name. This has several benefits:
- Links across site do not need to be updated.
- Google index stays the same, but with updated information.
- Speeds up replace workflow to be more intuitive.
Creating and Managing Documents
Creating documents
- Navigate to Content -> Add content -> Document.
- Fill out the fields:
- Title: The name of the document. This is not the name that appears in the file system or the direct URL. Only the URL for the document entity.
- File: The actual file entity itself. Upload your file here.
- File Format: Indicate what type of file it is.
- Date: Provides a relevant date for the file.
- Tags: Helps users find related items across the site. Tags are tied to pages, articles, documents and more.
- Thumbnail Image
- Category: Intended group of the files.
Managing documents
- Navigate to the Content dashboard in the admin menu bar.
- In the “Content Type” dropdown menu and select “Document”.
- You will be presented with a list of all your documents. From here you can sort/search for items, edit/delete documents using the dropdown on the right and bulk select items and execute actions on them.
Deleting Files
Files are tied directly to document entities now, so if you delete a document entity, it deletes the file too. This is different from the previous version where deleting a document entity did not remove the file from the file system. At that point the only way to delete the file was to open the IMCE file manager and delete it directly.
File replace functionality
A common use case while managing files is to update a document but retain the URL. This is to prevent outdated data from being available to users and google retaining that out of date file.
To replace a file:
- Navigate to the document entity with the associated file.
- Select edit.
- In the file field, select “Replace File”.
- You will be presented with a new page that displays the current file and a place to upload a replacement.
- If you would like to retain this file for any reason, now is when this needs to be done. After you hit save, this file will be deleted and replaced.
- Upload the updated version of the file.
- Save
- You will be returned to the document entity page.
- To confirm your file has been replaced, navigate to the presented link.