Problem/Motivation

I am working on a career match making portal for students. The taxonomy filter provides a nice way for students to search for an employer given the students competence tags.
When I came about to make the same search interface for employers - I found that I was limited to one url scheme for output links - limiting me to one filter page. This is not sufficient for this use case - and I suspect others as well - because the employers needs to search for students, and students search for employers - employers should not see other employers - and students not other students.
I could make variants in my panel based on users roles - but I prefer separate urls for easier navigation and browser history.

Proposed resolution

Some possible solutions:

Additional url format placeholder: %filterpagepath
This would solve my use case challenge by prepending the the current view/panel path to the /%tids/%depth etc variables.
Leaving only %tids/%depth in the format field
This could result in a default behaviour of appending %tids/%depth to any url path where the filter blocks are displayed

I have not analyzed if these are the only solutions to my use case challenge, or which of the two are desireable, but I think at least the first proposal could work. Maybe this is doable through some context / panel parameter tricks that I have not succeeded in trying because I am a pretty new drupal user.

Remaining tasks

Adding explanation of how to use
Explain the additional behaviour of the url pattern on the taxonomy_filter/advanced admin page
Adding filter behaviour
I guess it is located in function taxonomy_filter_filter_link_tokens in taxonomy_filter.module

User interface changes

Adding explanation of how to use
Explain the additional behaviour of the url pattern on the taxonomy_filter/advanced admin page

API changes

I dont think there are any changes here

Comments

solotandem’s picture

Good suggestion. The question is how to associate the URL with the filter blocks. The current structure seems inadequate to the task.

In your use case:
- do you have multiple filter blocks (e.g. for each vocabulary)?
- are the blocks mutually exclusive or shared (e.g. is there a vocabulary used for employers and students)?
- would it make sense to have multiple "filter menus" each with its own settings (e.g. including the URL) and consisting of various filter blocks (related to each vocabulary)? (see below)

On the last item, if a given vocabulary is used in multiple "menus," then the settings for the menu will determine the URLs output on the links.

grahamtk’s picture

I think it might be possible to use a universal substitution, if its possible to get the path when the taxonomy_filter_filter_link_tokens function is called? (upon the showing of the filter blocks) - thus allways returning the path on which a block is placed.
I tried with this code in a temporary experimental fix:

function taxonomy_filter_filter_link_tokens($tids = array(), $depth = 0, $op = '') {
  drupal_set_message(str_replace(base_path(), '', drupal_get_path_alias(request_uri(),1)));
  return array(
    '%tids' => implode(',', $tids),
    '%depth' => ($depth) ? $depth : '',
    '%op' => ($op) ? $op : '',
    '//' => '/',
    '%pagepath'=>str_replace(base_path(), '', drupal_get_path_alias(request_uri(), 1)),

however - it gives me path+ arguments..
also - str_replace might be a bit expensive - as it is run for every tag.. so it should perhaps be done in another function? If you think it is feasible to get the page part of the path in a consistent way?

stackoverflow.com question about drupal paths

grahamtk’s picture

To answer your questions:

- do you have multiple filter blocks (e.g. for each vocabulary)?
I have 1 of each blocks (search result / current filter criteria / specify more criterias menu) on each of the two pages - ( the one for student, and the other for employer).

- are the blocks mutually exclusive or shared (e.g. is there a vocabulary used for employers and students)?the vocabularies are the same, the only difference are the objects searched for. (e.g. student and employer). However - I think there may be differences in how the blocks are used in the two views - as students will use few tags, and employers many tags - so I would consider using different menu types at least. maybe some kind of multi level hierarchical select menu in the future. ( like the one in the hierarchical select module).

- would it make sense to have multiple "filter menus" each with its own settings (e.g. including the URL) and consisting of various filter blocks (related to each vocabulary)? (see below)
It might be productive to have different menu types for different vocabs - as some vocabs are large and some small, some hierarchical in nature and some list-like

On the last item, if a given vocabulary is used in multiple "menus," then the settings for the menu will determine the URLs output on the links. That would make it fleksible enough - but it is less administrator-friendly - as you have to configure it - if its possible as I suggest - to detect the page path, it would not have to be configured at all - the %pagepath token in the url template could be there default. As it is a filter used on a given page - connecting the term-refinement urls to the page where the menu resides on, and not is more intuitive I think.

grahamtk’s picture

Some experiment test results:
This found the current path in my case:
dirname(substr($drupal_url, strlen(base_path()), strlen($drupal_url)))

I think this is better than just request url, but don't know why an alias would make a difference here.
$drupal_url=drupal_get_path_alias(request_uri(), 1);

and this part is to get away any configured base_path as a relative path is better I think,
substr($drupal_url, strlen(base_path()), strlen($drupal_url))

the dirname sorts away the parameters, but wouldn't work if depth was part of the url..

grahamtk’s picture

To your last question about separate config for different menu locations / contexts -
one useful aspect in my use case is to specify which content type should be counted in the count showed besides terms.

Thus enabling me to show to employers the number of students mathcing in their view, and show students the number of interested on a given term. :)

grahamtk’s picture

May I ask a side question?
Is it possible to show the filter menus even when no terms are shown?

Per now I have to configure the views to show all content when no term is specified,
and also show all tags in a block (per vocab) from a custom view of the terms - to provide a "one term" filter to start off with.

solotandem’s picture

This question has been asked before. It seems to be circular in that:
- the menus are triggered by a taxonomy term URL
- the filter blocks are dependent on the vocabulary of the term in the URL
- if there is not such a URL, then how would this module know what to display

I am open to suggestions.

grahamtk’s picture

The filter would be usabel more places if its default behaviour was not to hide, but to show all terms.
what vocab the menu shows is already defined in the admin ui, is it not?
what more info is needed from the url?

Also - I have met an interesting limitation in the count stats on terms - it would be great to be able to specify what content types are counted..

per now the filter shows both interested employers and interested students in the same count -
making it less useful to both students and employers.

thanks for a great module anyway.