We have many Views and Views displays. Over 3 years of building the site we have many displays that are not being used. We would like to delete them and clean up the view but are concerned that a display might be used in the site. Is there a way of determining if a views display is being used on the site? I thought of different ways to check this:
- A View display that is a Page will have a URL path. Check the path to see if it is working.
- A View display that is a block display will be in Managed Blocks. Go to Managed Blocks and see if is placed in any region.
- You can look at the view display machine name. And see if there are any twig templates that match that name.
- Also do a grep search in our templates for the display machine name to check if it printed in a twig template.
Views
hook ortemplate_preprocess_views_view()
on a development copy of the site? Use a site crawler on the dev site to go to every page, or enough pages/depths, and save the name and/or id of the views and displays somewhere (text file, database, etc). Also use "Views::getAllViews()" along with$view->storage->get('display')
to create a second list of all views/displays. Finally, use aSQL
query ordiff
the files to see which views/displays weren't... viewed/displayed during the crawl.