Closed (fixed)
Project:
Hierarchical Select
Version:
5.x-3.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
8 May 2008 at 02:06 UTC
Updated:
24 May 2008 at 15:23 UTC
This may be a self-asign, but I'll ask first in case plans are in place.
It would be very useful to add the number of available nodes in each potential selection, in a yelp-like style: for instance, how may restaurants and cafes match the current selection of city, and if restaurants are selected, how may restaurants there are in each of the available cities.
I need to hack this for a client within the next week, so wanted to ask in case there are any plans-in-place, or in case it is best to get tips about how it would be best to implement to be useful to the project.
Also, of course, as I've just +1-ed, to work with a dynamic select version of HS.
Thanks!
Comments
Comment #1
wim leersThere's an issue for that, and it's the oldest one in the queue: http://drupal.org/node/180691.
There's two ways:
- the proper way, which would be supporting this in Hierarchical Select itself, i.e. through an abstraction. All what would be needed per implementation is a hook that, given an item, returns the number of children (i.e. a simple COUNT() query). Via the configuration, you could then enable or disable this.
- the hacky way, which is by modifying the taxonomy implementation (modules/taxonomy.inc), and change the labels of each item, to list the number of children. The obvious disadvantage is that you'd have to repeat the same thing for every implementation of the Hierarchical Select API.
I'll go through the code today to describe more accurately how the proper way would work.
Comment #2
wim leersYou could do this by appending your code to
_hierarchical_select_hierarchy_generate(). To get started:- the
$hierarchyobject is what you want to modify. This is what dictates what will end up in the selects- you'll want to use the
hook_hierarchical_select_valid_item()hook to only retrieve the number of children for items that are reallypart of your hierarchy
- you'll also want to add a new hook (
hook_hierarchical_select_child_count($parent, $params)) to retrieve the number of children of a given item.If you can provide this code *without* providing a setting to the end-user, I'll take care of that part. Let me know if you need any more information!
Comment #3
wim leerspatchak is sponsoring this feature. Will be implemented very soon.
Comment #4
wim leersComment #5
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.