[drupal-devel] [feature] Make taxonomy selection widget themable

Bèr Kessels drupal-devel at drupal.org
Mon Sep 12 18:46:06 UTC 2005


Issue status update for 
http://drupal.org/node/30993
Post a follow up: 
http://drupal.org/project/comments/add/30993

 Project:      Drupal
 Version:      cvs
 Component:    taxonomy.module
 Category:     feature requests
 Priority:     normal
 Assigned to:  robertDouglass
 Reported by:  robertDouglass
 Updated by:   Bèr Kessels
 Status:       patch (code needs review)

note: I tested the first patch, not the last.




Bèr Kessels



Previous comments:
------------------------------------------------------------------------

Mon, 12 Sep 2005 13:48:13 +0000 : robertDouglass

Attachment: http://drupal.org/files/issues/taxonomy.txt (4.32 KB)

The taxonomy select widget becomes unmanagable very quickly. If there
are more than two levels in a hierarchy or more than X number of terms,
it is almost impossible to use. This patch makes it a themable element
so that creative UI designers can start cooking up better solutions.
Here are the changes, in detail:



* There is a new function theme_taxonomy_term_select which is a carbon
copy of the old _taxonomy_term_select, plus XDoclet comments.
* The old _taxonomy_term_select function calls the theme function using
the theme() syntax.
* taxonomy_form  has an extra parameter $title = NULL so that the label
on the form can be set by the public API. When NULL it defaults to the
vocabulary name as usual. The reason I need this and I think Drupal
needs this is that taxonomy is really useful for lists of items that
need to be reused. Take the list {good, bad, ugly}. This set of terms
could describe lots of things, defying any attempt to give the
vocabulary a catchall name. Now, with the updated taxonomy_form, I can
create a form element called 'Rate my code' and get the abovementioned
list. In the same form I could have another element called 'George Bush
is' and use the same list over again.
* taxonomy_form now has XDoclet comments.



------------------------------------------------------------------------

Mon, 12 Sep 2005 14:20:48 +0000 : moshe weitzman

great patch. this widget could certainly be prettier, especially for
small vocabularies (i.e. radio buttons or checkboxes). themers will
make that happen.


- is there any reason to keep _taxonomy_term_select(). You could call
the theme function directly from taxonomy_form()
- if we do keep it, perhaps collect $tree there and then pass $tree to
the theme function.




------------------------------------------------------------------------

Mon, 12 Sep 2005 14:24:58 +0000 : robertDouglass

I wanted to gather feedback before I deprecate or remove 
_taxonomy_term_select().


"perhaps collect $tree there and then pass $tree to the theme function

"
How do you think this would be easiest for themers?




------------------------------------------------------------------------

Mon, 12 Sep 2005 14:32:32 +0000 : mgifford

We have used this for some of our select lists for our other CMS (Back-
End.org):
    http://www.barelyfitz.com/projects/filterlist/


Might be worth considering bringing it over to Drupal.


There are other ways of approaching this too, but this seems to be a 
fairly easy way to deal with long lists.


There are some other javascript solutions that might be more
applicable, but this is one of the few that is clearly GPL.


Mike




------------------------------------------------------------------------

Mon, 12 Sep 2005 15:52:57 +0000 : Robrecht Jacques

+1


I especially like the link mgifford provided: this would make it _very_
easy to select long taxonomy lists! (although that example only allows
for single select, right?). This is not possible with current drupal,
but providing the theming function someone could easily implement it.
This would make using (and reusing) taxonomies much easier.


As for passing $tree or not. I actually prefer to have $vid only, not
$tree as sometimes you don't need $tree at all.




------------------------------------------------------------------------

Mon, 12 Sep 2005 16:04:16 +0000 : Prometheus6

+1, definitely.




------------------------------------------------------------------------

Mon, 12 Sep 2005 16:14:03 +0000 : moshe weitzman

Folks - when an issue is in 'needs review' status, we expect a *patch
review* to be posted. Guidelines for a patch review are at
http://drupal.org/patch/review. I encourage everyoen to reread that
page. We specifically discourage a simple +1 or -1 in a patch review.


I will be enforcing these guidelines for a while, as the quality of
patch reviews has decreased recently. If you have issues/questions,
pelse email me directly. I'd rather not hijack this fine patch.


-moshe




------------------------------------------------------------------------

Mon, 12 Sep 2005 16:43:18 +0000 : Robrecht Jacques

Ok, let's re-review:


1. I think the functionality added is needed and can't be achieved in
any other way. The theming of a taxonomy select form will add usability
in both small vocabularies (eg replacing it with checkboxes if only a
few terms) and large vocabularies (see the example above).


2. The code degrades to exactly the same functionality as is now if no
theming function is defined.


3. I have tested the patch:
- it applies cleanly.
- the taxonomy form is shown as before.


4. The code is well documented. It confirms to the coding style.


5. I do not like moshe's suggestion to pass $tree: not all
implementations of this would need $tree. If the themer needs $tree, he
can easily call taxonomy_get_tree() like is done.


6. I notice that _taxonomy_term_select() is called on other places in
taxonomy.module too. Can you use the theme function there too?




------------------------------------------------------------------------

Mon, 12 Sep 2005 17:05:13 +0000 : robertDouglass

Attachment: http://drupal.org/files/issues/taxonomy_0.txt (6.09 KB)

_taxonomy_term_select would now be deprecated. Modules that would need
to update include:
amazontools
distantparent
eatlocal
flexinode
groups
image
img_assist
import_export
quotes
remindme
taxonomy_access
taxonomy_assoc
taxonomy_otf
trip_search


These modules will still work, though even without being upgraded.
Please test as this patch changes more code.




------------------------------------------------------------------------

Mon, 12 Sep 2005 18:04:05 +0000 : Prometheus6

Not only does the patch work, I'll be looking at it to see if something
similar can be done for book/outline handling. I started a patch that
split the Parent combo into two that cascaded changes, but it does not
degrade at all...I didn't consider theming as a way to do it.


I also need to use this widget, but with a different label, in another
project...right now my only option is a mass of duplicated code.




------------------------------------------------------------------------

Mon, 12 Sep 2005 18:45:14 +0000 : Bèr Kessels

+1 works as expected.
* I can now style voc X different from voc Y, wohoo!
* I really like this workflow: first let contribs "fight" for the best
implementation, then in future evaluate the winners to go in core as
default. 


I hope this is still in time for 4.7.....







More information about the drupal-devel mailing list