I would like to have CMF apply a filter by default, so that the node list opens up with that filter already in place. Even better if it was a negative one, i. e. exclude nodes with the selected value.
Reason: a site has a couple of content types with hundreds of technical nodes, i. e. nodes that no one needs to display or edit, but that must exist for list and signup purposes. They fill up the node list, making it longer for site admins to locate real nodes to edit. Admins must always set the content type filter to something, to hide the useless nodes. This would be better if CMF supported default filters, perfect if that default would be of the excude type.
CMF supports custom filters. I see the default one as a custom filter with auto-execute option. The usual text would appear, and the filter would be removed by the standard undo/reset buttons.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 1111660-get-params-filtering-2.patch | 795 bytes | coredumperror |
Comments
Comment #1
coredumperror commentedI'm looking for a similar feature, and I think it would cover this user's request as well.
I'm writing a module that creates a Dashboard for my site's content editors. Most of them are fairly non-technical people, so I want the Dashboard page to have links that bring them to parts of the site that are pre-configured for absolute maximum ease of use.
For instance, I'd like to be able to craft a link that brings them to the CMF page that's pre-filtered to show only image file nodes. That way they don't need to do the extra step of manually filtering by image files every time they click through from the Dashboard.
From my quick perusal of the code, it seems like CMF uses the login session to store which filter should be applied. Would it be possible to override the session data when GET vars are passed to admin/content/filter, so that different links can lead to differently pre-filtered results?
I could write a patch for this functionality myself, but my own knowledge of how this module functions, and how to retrieve GET params from within the page building functions is sorely lacking. If someone could suggest where to learn the technique for these things, I'd happy to write a patch, since my clients would be very happy to have this kind of functionality.
Comment #2
coredumperror commentedI made this patch to enable the use of HTTP GET parameters for filtering. Use a URL like:
example.com/admin/content/filter?type=page
And a filter based on node type of "page" will already be applied when your user arrives on the page. The presence of any GET params on the URL automatically clears all the other filters saved in the current session.
Since the session stores which filters are currently applied, you may want to craft a link that resets the filtering without having to actually click the Reset button on the filter page. With this patch you can do that:
example.com/admin/content/filter?reset=1
I haven't done exhaustive testing on this patch, but it seems to be pretty solid from the use I've made of it on my own site. It's a totally non-intrusive change, too, since there's no other code in CMF that deals with or expects GET params. This patch only adds a dozen lines of code, without changing any existing code, and that code is enclosed in an if block that only actives if GET params are present.
Comment #3
mdorrell commentedI had to do something similar, and created a hook_menu callback that set the session variable, then used drupal_goto to redirect to the cmf page. If you create a temporary hook_form_alter and print out the $_SESSION['cmf_overview_filter'] variable, you can figure out what values you need to set in the session array.
Here is my hook_menu callback that sets the content type and the language.
Comment #4
daniel wentsch commentedThanks for your patch coredumperror, just what I needed.
I've found one issue though and would like to know, if you've got the same problem:
The pager doesn't work anymore as soon as I filter by GET variables.
The pager is there, but as soon as I click any link I get the message "Filter returned no results."
The URL looks like this: admin/content/filter?page=2&type=adb_leistung
If I switch the URL parts and manually put the page parameter at the end it seems to work: admin/content/filter?type=adb_leistung&page=2
I don't have a clue how to do this programmatically though.