Integrate with core taxonomy

Amitaibu - May 9, 2008 - 20:44
Project:Workflow-ng
Version:5.x-2.x-dev
Component:Wng Module Integration
Category:feature request
Priority:normal
Assigned:Unassigned
Status:patch (code needs review)
Description

Attached patch has 3 actions:
Load existing vocabulary
Add and load a new vocabulary
Add a new term (you must load a vocabulary first)

AttachmentSize
wfng_taxonomy_1.patch8.59 KB

#1

fago - May 13, 2008 - 13:33
Status:patch (code needs review)» patch (code needs work)

interesting, thanks

-> you can shorten this code by just using array_filter($form_values['nodes']).

+ foreach ($form_values['nodes'] as $key => $node_type) {
+ if (empty($node_type)) {
+ unset($settings['nodes'][$key]);
+ }
+ }

this doesn't look good?
+ $settings['weight_vocabulary'] ? $settings['weight'] = $settings['weight_vocabulary'] : $settings['weight'] = 0;

It'd better be
$settings['weight'] = $settings['weight_vocabulary'] ? ...

Anyway, you could save this all, by just using $settings['weight'] everywhere, but don't using $form['weigt'] and adjusting the name in the submit handler $settings['weight'] = $form_values['form_name'];

I need to give this more testing, anyway I'd prefer more node related taxonomy integration like: Assign a term to a node + Remove a term from a node.

#2

Amitaibu - May 13, 2008 - 16:22

Fago,
Thanks for the review, I'll work on the code.
I thought of doing this patch in steps, i.e. start with those basic actions and then extend them - too big patch is prone to no-review ;)

#3

Amitaibu - May 20, 2008 - 13:18

Here's the new patch with node related actions.

1. Load vocabulary - should be used in order to add and load a new term.
2. Load term - Should be used in order to add/ remove term to/ from content.

I didn't get how you want to deal with the $settings['weight'] so left it as is.

AttachmentSize
wfng_taxonomy_2.patch13.18 KB

#4

fago - June 20, 2008 - 12:07

hm, let me explain it better.

as for the form 'weight' can'T be used you can use, e.g. 'vocabulary_weight'.

The in your forms submit handler you return the settings as array('weight' => $form_values('vocabulary_weight')). So the value ends up in $settings['weight'] - where you can use it for setting the #default_value for the form element 'vocabulary_weight'.

#5

Amitaibu - June 20, 2008 - 15:10
Status:patch (code needs work)» patch (code needs review)

Ok, I think I got it now :)

Edit: as always, the drupal upload bug...

AttachmentSize
wfng_taxonomy_3.patch13.05 KB

#6

jimi089 - July 16, 2008 - 03:23

When I added the latest patch as the two .inc files, I got an error when trying to add a vocab:

Parse error: syntax error, unexpected T_VARIABLE in /sites/all/modules/workflow_ng/workflow_ng/modules/workflow_ng_taxonomy_forms.inc on line 44

#7

Amitaibu - July 16, 2008 - 11:53

I'm unable to reproduce the error, please send a screenshot of your form.

#8

jimi089 - July 17, 2008 - 00:45

I think there was an issue with my patch, I ran it again and it worked fine.

I'm a bit confused about the methodology for removing taxonomy terms. I have used the patch to add them fine, but not remove existing terms. Any help?

#9

Amitaibu - July 17, 2008 - 09:03

Removing a term isn't yet implemented. Let's start with the existing patch and then extend it.

 
 

Drupal is a registered trademark of Dries Buytaert.