Digital.Grinnell employs a custom-built Drupal “view” we call the dg7 Collection View; it’s part of the code in our custom dg7 module where all of Digital.Grinnell’s hook implementations are also defined. Experience leads me to beleive that keeping a complex Drupal view in code is prudent, but overriding that code with a database copy of the view helps tremendously in terms of system performance. So, I recommend keeping the view code in the module, but that means that when significant changes are made, like the addition of a new colleciton, the code should be updated in the database to speed things up. Digital.Grinnell employs the following workflow to keep the view in code, but allow it to be selectively updated in the database as needed:

  1. Put the site into Maintenance Mode. Drupal’s default behavior with views in code is to reload and cache views every time they are needed. If/when the cache is cleared or expires this default process can be quite time-consuming, so it’s prudent to take control. Putting the site into Maintenance Mode helps in this regard because the dg7 module is coded to ONLY update the dg7 Collection View while the site is in that mode.

  2. Visit the admin/structure/views page and DELETE the existing dg7 Collection View from the database. Deleting the view triggers the system to re-populate it, something that only happens if the site is in Maintenance Mode.

  3. Clear all caches to complete the reset of dg7 Collection View. An easy way to do this is to execute the following command on the DGDocker1 host:

docker exec -w /var/www/html/sites/default isle-apache-dg drush cc all

When you return to the site you should now see messages like this:

dg7_views_default_views has been called in MAINTENANCE MODE and dg7_collection does not exist so it will be created.

Note that you MUST alter the new dg7_Collection view in order to secure the new definitions in the database! It's easy, just edit the view and update all display titles to be empty. Do NOT delete the existing dg7_Collection view again unless you want to force an update from this code in MAINTENACE MODE!
  1. Force the view to refresh back into the database. Visit the admin/structure/views page, click Edit for the dg7 Collection View, click Title: none, then click Apply (all displays), and finally click Save. This action changes NOTHING, but it does force the view back into the database where the dg7 module code is overridden.

  2. Take the site out of Maintenance Mode. Visit the site’s admin/config/development/maintenance page, remove the Maintenance Mode checkmark, and click Save configuration.

This workflow was written for the production instance of Digital.Grinnell, but the same can be applied to local development or staging instances of Digital.Grinnell simply by changing URLs as needed.

And that’s a wrap. Until next time… 😄