With the addition of Views in Drupal core, many of the administrative interfaces are powered by Views. This allows customization of default admin interfaces to enhance site management and content authoring experiences.
In this recipe we will modify the default content overview form that is used to find and edit content. We will add the ability to filter content by the user who authored it.
/admin/content
when managing content./admin/content
and you will have your filter. Content editors will be able to search for content authored by a user through autocompleted username searches:When a view is created that has a path matching an existing route, it will override it and present itself. That is how the /admin/content
and other administrative pages are able to be powered by Views.
Drupal uses the overridden route and uses Views to render the page. From that point on the page is handled like any other Views page would be rendered.
We will dive into additional features available through Views that can enhance the way you use Views and present them on your Drupal site.
Filters allow you to narrow the scope of the data displayed in a view. Filters can either be exposed or not; by default a filter is not exposed. An example would be using the Content: Publishing status set to Yes (published) to ensure a view always contains published content. This is an item you would configure for displaying content to site visitors. However, if it were for an administrative display, you may want to expose that filter. This way content editors have the ability to view, easily, what content has not been published yet or has been unpublished.
All filter and sort criteria can be marked as exposed.
Exposed filters work by parsing query parameters in the URL. For instance, on the content management form, changing the Type
filter will add type=Article
amongst others to the current URL.
With this recipe the author filter would show up as uid in the URL. Exposed filters have a Filter identifier option that can change the URL component.
This could be changed to author
or some other value to enhance the user experience behind the URL, or mask the Drupal-ness of it.
Views is able to replace administrative pages with enhanced versions due to the way the route and module system works in Drupal. Modules are executed in order of the module's weight or alphabetical order if weights are the same. Naturally, in the English alphabet, the letter V comes towards the end of the alphabet. That means any route that Views provides will be added towards the end of the route discovery cycle.
If a view is created and it provides a route path, it will override any that exist on that path. There is not a collision checking mechanism (and there was not in Views before merging into Drupal core) that prevents this.
This allows you to easily customize most existing routes. But, beware that you could easily have conflicting routes and Views will normally override the other.