I'm trying to make my URLs a bit more readable (and persistent) which includes query parameters of a view's page. Usually the URL would look like this when I define an exposed filter which is addressed by the parameter vocabulary-foo
: https://www.example.com/view?vocabulary-foo[]=1234
. As you might have noticed, this is a filter for taxonomy terms of a specific vocabulary. There are two problems with the usage of IDs in the URL, which I'd like to solve:
If I uninstall my custom module that creates the taxonomy terms, these are gone and will get another ID when I install the module again. So I can't assume a link to a specific filtered view page would then still be the same.
It's not readable (and memorizable). Using the term's value instead of the ID would probably already help me. On the other hand, if it is possible to define a query parameter
preset=something
which translates tovocabulary-foo[]=<The id of the term which has a specific value>
, I'd rather do that as it enables me to combine multiple query parameters to one preset, which makes it shorter.
In my specific case, the view exposes a form which can be used to search for content. A preset as described would pre-select some form controls with only one clean URL parameter.
One idea that came to my mind was somehow using PHP's $_GET
variable and conditionally changing its content before the view is created. Unfortunately, I don't know which hook would be suitable for that.
Has somebody faced a similar issue in the past? How could I solve these problems in Drupal 9? Thanks!