The core Taxonomy module has a taxonomy_override_selector variable that allows for third party modules to define custom selectors. See line 490 of the modules/taxonomy/taxonomy.module file. The most notable project that makes use of this functionality is the popular Hierarchical Select module. In order to facilitate integration with projects like Hierarchical Select, User Terms should implement something similar. In the spirit of consistency, I propose that this module define a user_terms_override_selector variable so that other modules can override the Taxonomy selection element in the user edit form. As a side note, I am submitting a User Terms integration module to Hierarchical Select and will post a link to it it this thread.

Thanks,
Chris

CommentFileSizeAuthor
#1 user_terms-744044-1.patch3.69 KBcpliakas

Comments

cpliakas’s picture

Status: Active » Needs review
StatusFileSize
new3.69 KB

The attached patch adds this functionality to User Terms.

Thanks,
Chris

cpliakas’s picture

The integration piece for Hierarchical Select has been posted at #744064: Integrate with the User Terms project, however as stated above it depends on adoption of this patch.

cpliakas’s picture

(Content removed, accidentally posted duplicate. Sorry!)

joachim’s picture

So just checking I've understood this correctly:

If module foo sets 'taxonomy_override_selector' to TRUE, that causes taxonomy to do nothing to the node edit form, and module foo guarantees it will do something there instead.

And I take it the patch is just wrapping all the form generation in a variable check, just that patch goes a bit funny with indentation changes?

cpliakas’s picture

Hi joachim.

You are exactly right on both accounts. The patch really only adds two lines of code, one being the variable conditional and the other being a curly bracket closing the code block. All of the other changes are code indentations inside the newly created block, so the patch definitely looks 100 times more complex than it actually is :-).

The integration module posted at #744064: Integrate with the User Terms project simply sets the user_terms_override_selector variable to TRUE in hook_enable() and FALSE in hook_disable(), then it adds the replacement hierarchical select form via hook_user(). This is on par with how other modules that make use of the coretaxonomy_override_selector variable. When user_terms_override_selector is set to TRUE, the "form" and "register" $op values in user_terms_user() will return nothing. The hs_user_terms module then adds the replacement form for the same $op values in its hook_user() implementation. Since the form is structured the same way, it integrates well with the other $op values in user_terms_user() (i.e. "insert" and "load").

Thanks,
Chris

joachim’s picture

Status: Needs review » Reviewed & tested by the community

Cool.

In which case, I'll commit this later.

You may want to bear these in mind: #728972: Terms are clobbered by user operations when terms are on account, #656428: Multiple vocabularies assigned to abitrary profile categories as they may affect you.

cpliakas’s picture

Thanks for the feedback and advice. Obviously this method in the patch is a bit inflexible, but I like to mimic what core does simply to avoid WTF moments. The Hierarchical Select maintainer likes the idea of integration, but he is understandably reluctant to add the integration piece to the core Hierarchical Select module. I am hesitant to pick it up because I have a bunch of other modules to maintain, but it may be a cool sub-project to start or add as a contrib to this module.

Thanks again,
Chris

joachim’s picture

I think this needs a fresh issue :)

I'll commit the patch tonight and close this one.

cpliakas’s picture

Sounds good. No need for another thread re: the integration as I bit the bullet and created a project at http://drupal.org/project/hs_user_terms to integrate this module with Hierarchical Select. I will stop bringing it up here :-).

Thanks for your feedback and quick responses,
Chris

joachim’s picture

Status: Reviewed & tested by the community » Fixed

Committed a slightly modified version of the patch: added a comment to explain, and also put the return inside the conditional (as otherwise we're returning a $form that hasn't been set).

#744044 by cpliakas: Added an override for third party modules to add custom selectors.

joachim’s picture

Congrats on the new project btw :)

I plan to make a full 1.0 release of this once those two issues I mentioned are dealt with.

cpliakas’s picture

Thanks for your attention to this, and also good catch re: #10. We will also be following the march towards 1.0. The new project will transition to a new maintainer shortly, but I look forward to collaborating on D.O. until that time. Also, the integration piece is now listed on the Hierarchical Select page, so that may help drive some traffic to User Terms.

Thanks again,
Chris

joachim’s picture

Just to let you know I've released beta 4 :)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.