views_pretty_paths
Introduction
Views Pretty Path rewrites URLs associated with Views into into a more user- and SEO-friendly format.
For example, Views Pretty Path would take this URL:
And rewrite it as:
http://example.com/blog/filter/assets/article/topics/technology/keywords/blockchain.
Requirements
No special requirements.
Recommended Modules
No recommended modules.
Installation
- Install as you would normally install a contributed Drupal module. See: https://www.drupal.org/node/895232 for further information.
Configuration
The configuration form can be found at /admin/config/views-pretty-path.
Set the paths to rewrite (prepending a '/' slash), the view each path will be associated with, and the display of that view from which filters will be considered by Views Pretty Path during rewriting. Views Pretty Path will then check against this list, and if a request path matches one of the paths set in the form, query parameters will be rewritten according to the filters in the selected view.
A mapping betweeen views filter identifiers and user-defined names can also be set (e.g. 'field_topic_target_id' is rewritten as 'topics'). Use the following syntax, each rule separated by a new line: filter_identifier|name
Lastly, a filter subpath can be set (i.e. 'http://example.com/blog/filter/{term1}/{term2}' has the subpath of '/filter'). The default subpath is '/filter'.
Extending
A view may use a filter that is currently not supported by Views Pretty Path. In that case, a custom Views Pretty Path filter handler service can be created in a custom module that implements Drupal\views_pretty_paths\FilterHandlers\ViewsPrettyPathFilterHandlerInterface, extends Drupal\views_pretty_paths\FilterHandlers\AbstractFilterHandler and uses the 'views_pretty_paths_filter_handler' Symfony service tag. For an example, see views_pretty_paths.services.yml and Drupal\views_pretty_paths\FilterHandlersTextFilterHandler. Implement the getTargetedFilterPluginIds() method to select which Views filter plugin IDs to target with a custom filter handler.