How to bulk edit cck fields?

negro12 - January 14, 2009 - 08:20
Project:Views Bulk Operations (VBO)
Version:6.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:kratib
Status:closed
Description

How could i edit cck fields by this module? or are there any other solutions?

#1

kratib - January 14, 2009 - 09:12

You need to write an action (in your own module) that exposes a form to capture the new value from the user. VBO will automatically detect that action and you can enable it in the view settings. Refer to taxonomy.action.inc for an example.

#2

negro12 - January 15, 2009 - 01:19

Get it, thanks!

#3

kratib - January 15, 2009 - 07:17
Status:active» fixed

#4

dww - January 16, 2009 - 17:09

I haven't used it, but someone recently pointed me to http://drupal.org/project/editablefields for this sort of thing...

#5

rayvaughn - January 17, 2009 - 13:50

Did you write a an action to edit a cck field? If so if you can post it here as an example if would be much appreciated

TIA

marcus

#6

opensanta - January 17, 2009 - 16:24

Starbow may have you covered on this: http://www.starbowconsulting.com/node/116

You could also take a look at Field Actions.

#7

rayvaughn - January 17, 2009 - 18:33

I had a look at VBO but it seemed designed to perform the same action on a set of nodes defined by the view. For example: unpublish all.
But to provide an edit drop down for each node in a list in order to change the value of a cck field?
How will field actions help here?

#8

dww - January 17, 2009 - 19:25

@rayvaughn: http://drupal.org/project/editablefields is supposed to do that.

#9

rayvaughn - January 17, 2009 - 21:07

Yes but its Ajax only and the javascript falls over with 30 nodes in a list. I've posted a bug report. Thanks for the help though... I realise now that VBO is not intended to resolve this need.

#10

kratib - January 20, 2009 - 22:30
Status:fixed» closed

#11

stacysimpson - February 27, 2009 - 19:40

Did you write an action to mass update CCK fields, which hooks into VBO. I would appreciate if you could share. Thanks!

#12

kratib - February 28, 2009 - 17:22
Category:support request» feature request
Assigned to:Anonymous» kratib
Status:closed» active

FYI, the fieldactions module only exposes the following actions:
* Change node author based on a user reference field (fieldactions_assign_owner_to_userreference_action)
* Send email to a user reference field (fieldactions_send_email_to_userreference_action)
* Send email to the author of the node selected in the node reference field (fieldactions_send_email_to_nodereference_action)
* Send email to the creator of the node (fieldactions_send_email_to_owner_action)
* Send email to the value of an email widget field (fieldactions_send_email_to_email_action)
which is not what is sought in this issue.

Also, editablefields is not suitable because it allows to change each field *per row* which is not what's required either.

So what's needed is a new action that does the following:
* Expose a config form that allows to choose one or more fields from a specified content type, and to let the user specify values for each chosen field.
* Apply the chosen values to the corresponding fields of each node that's passed to it

Through VBO, one would then be able to select a bunch of nodes and set some fields to a desired value in *all selected nodes*.

#13

stacysimpson - March 2, 2009 - 18:08

kratib, that's exactly what we need. The 'Action Views' module, http://drupal.org/project/action_view, provided a similar capability in D5; however, it hasn't been ported to D6. The Bulk View Operations or CCK would seem like the logical places to incorporate the feature.

fyi...I opened a separate feature request against CCK, http://drupal.org/node/386146, as I didn't know if this thread would be re-opened.

We are willing to help test or whatever.

#14

kratib - March 6, 2009 - 20:12
Version:6.x-1.3» 6.x-1.x-dev
Status:active» needs review

The latest VBO dev release (which will be available 12 hours from now) contains a new action called "Modify node fields" that implements the spec above. It's still pretty rough around the edges but I was able to modify field values with it. I'll try to add the standard, non-CCK fields but I'm still not sure how.

Please try it and send your feedback on this thread (until it's officially released). Specifically, I'd be very grateful if you could try out different types of CCK fields and notify me of their behaviour. Thanks!

#15

stacysimpson - March 10, 2009 - 14:31

I installed the dev release dated '2009-Mar-10'.

Problems:
- When attempting to edit a text field, it didn't work. Error message:

    * warning: Invalid argument supplied for foreach() in /media/storage/www/drupal6/sites/all/modules/views_bulk_operations/fields.action.inc on line 97.
    * You must select at least one field to modify.

- Also, noticed the allowed values for a text - select list widget do not pre-populate. Just blank.

So, I wasn't able to do too much.

Feature Requests / Questions:
- No option in the table to "select all" displayed nodes.
- Is the module configured to create new node revisions when updating? If so, our site is configured to require a node revision log message when creating new revisions. Can this be exposed as well?
- Usually, we only need to update a particular field at one time. How difficult is it to only display certain fields and manage this on a view basis?
- All the PHP code text fields display without any header / description information, so it's hard to tell which one goes with which field.

#16

kratib - March 10, 2009 - 16:27

Thanks for your feedback. I'll work on the issues you reported.

Concerning the single-field update, I think I will postpone this feature because it will require to have per-action, per-view administration screens which is not built in the actions framework of Drupal currently.

#17

kratib - March 11, 2009 - 03:17

Hi stacysimpson, I committed some changes to the fields action, and I'd appreciate if you could take a look at it. Here's what you should find:

* The select all checkbox is there.
* The PHP code area is now highlighted with its corresponding field. I hope that's enough in terms of visual clue.
* I successfully tested against a text field with select widget, as well as node reference and user reference.

If the text field still doesn't work, please export your CCK type and paste it here. There are surely some setting combinations that I didn't try.

Thanks!

#18

kratib - March 16, 2009 - 02:49

The latest dev release contains support for common non-CCK node fields such as title, body, log, etc.

#19

stacysimpson - March 16, 2009 - 20:05

kratib, I see the 'select-all' checkbox and the non-CCK node fields are displaying now. However, something must be different in our installations because I'm still not seeing enough information on the view itself to perform a valid test.

Take the built-in 'Story' content type and attached screenshot for example.

There are 2 blank check boxes and empty text fields displayed above an 'Input Format' collapsible section. Below it are 9 blank check boxes and empty text fields. The top section seems to be correlated to the number of CCK fields that are part of the content type; however, I cannot tell what-is-what due to the lack of a field label.

I went ahead and entered random text in each of the fields and received the following error, "Parse error: syntax error, unexpected $end in /media/storage/www/drupal6/sites/all/modules/views_bulk_operations/fields.action.inc(142) : eval()'d code on line 1". Again, I have no idea what I was attempting to modify.

AttachmentSize
vbo.GIF 11.38 KB

#20

stacysimpson - March 27, 2009 - 19:41

kratib, well, I've finally carved out some time to dig deeper into the missing label issue. Unfortunately, I don't know PHP that well and don't see anything obvious. I tried comparing the non-CCK fields with the CCK field, but the form-related PHP trickeration has me lost. Any help is appreciated!

#21

kratib - March 27, 2009 - 22:08

Given your screenshot, I would say that the form action theme function is not being picked up. Please try to flush your Drupal caches and check again.

#22

patchak - March 30, 2009 - 12:35

Hey there I installed the latest dev version of this module, to try and change the values of some cck fields, but i get this error :

Fatal error: Unsupported operand types in /home/blogsurf/sites/intranet/sites/all/modules/views_bulk_operations/fields.action.inc on line 51

which is : $form[$field['field_name']] += array('#weight' => $weight++, '#prefix' => '', '#suffix' => '');

so not sure what is wrong here...

Any ideas?

Thanks,
Patchak

#23

kratib - March 30, 2009 - 18:17

@patchak: thanks for your report.
* Are you running this action as the site admin or as another user?
* Can you please insert a var_dump($field['field_name']); just before that line? I'd like to know which field is causing the error.

Thanks!

#24

gionnibgud - March 31, 2009 - 18:46

Hi I'm having the same Unsupported operand as patchak when selecting the change cck field action.
I've downloaded the latest VBO dev. D6.10. Updated releases of CCK and Views.
Here's my vardump

string(15) "field_tipologia"
string(17) "field_frif_biblio"
string(5) "title"
string(6) "format"
and then the fatal error.

Thanks!

#25

kratib - March 31, 2009 - 18:55

@gionnibgud: Thanks for your report. Are you running this action as admin or another user?

#26

kratib - March 31, 2009 - 19:59

I committed a fix in fields.action.inc to make inclusion of non-CCK fields more robust. Please try it (download the dev tar.gz package 12 hours from now or get from CVS directly) and let me know if it solves the "unsupported operand types" error.

#27

vanderlip - April 3, 2009 - 13:29

Sorry, I have probably missed something. After installing 6.X-1.x -dev from April 2 2009, the action "Modify node fields" seems to be missing from the list of option when selecting the Style gear. See attached. In addition, on the modules page of my site, the version number shows 6.x-1.3.

Thanks for any guidance.

AttachmentSize
vbo.JPG 48.04 KB

#28

kratib - April 3, 2009 - 20:32

@vanderlip: You are probably using an old version unwittingly. Please make sure that your modules folder(s) don't contain 2 VBO folders.

#29

vanderlip - April 7, 2009 - 18:14

Absolutely right. I somehow got a version of the module into the directory of another module. Sorry, for the fire drill. Thanks!

#30

stacysimpson - April 7, 2009 - 21:05

kratib, I installed the latest dev build from 4/7/2009. After clearing the views cache and page cache, I now see new form items listed for the CCK fields; however, I still see that large list of blank checkbox and text entry form items. The number of these blank (no-label) form entries still seems to be correlated with the number of fields associated with the content type.

1st attempt:
I tried to enter new content in the form items which now appear with appropriate labels (after flushing caches). However, when attempting to execute the action, I get a message that says, "You must select at least one field to modify."

2nd attempt:
I randomly tried to enable a few of (blank) checkboxes and enter text in the text fields without labels.

After confirming, I received the following error message:

Parse error: syntax error, unexpected $end in /media/storage/www/drupal6/sites/all/modules/views_bulk_operations/fields.action.inc(142) : eval()'d code on line 1

After navigating back to the view, I received the following message:

warning: Invalid argument supplied for foreach() in /media/storage/www/drupal6/sites/all/modules/link/link.module on line 200.

Looks like that the issue must be in the ordering / organization of the form elements. My attempt #2 must have tried to modify the values for one of my custom CCK fields.

I tried defaulting back to the default Drupal theme, disabling page caching, disabling view caching and still see the series of checkboxes and text form fields with no labels.

Is there any other information I can provide you on the form element / entities alignment and/or organization issue?

#31

kratib - April 8, 2009 - 04:31

@stacy: It still seems that the code doesn't reach the action form theming function. Can you please insert a couple of var_dumps to make sure? One at views_bulk_operations.module line 358: var_dump($function);. The second at fields.action.inc line 88: var_dump($field_name);. What do you get? Thanks for your patience!

#32

stacysimpson - April 8, 2009 - 13:36

Ah ha, found the culprit. There is a 'Merge single action's form with node selection view' setting when creating views that causes this problem. By deselecting, I see the form elements organized now as a table (on a separate page, which is fine).

screenshot of view option

I don't know if you can disable this or whatever, but toggle this option on to see what I was seeing. We will proceed to do a more thorough test with our CCK fields...it seems to be working much better now! Thanks again.

AttachmentSize
tmp.GIF 2.85 KB

#33

kratib - April 8, 2009 - 15:13

Thanks for sorting this out! I'll check out the mess created by merging the form.

#34

stacysimpson - April 8, 2009 - 21:08

kratib, excellent work here! I did not mess around with the 'PHP Code' option; only, static field content.

Feedback below:
1. Looks like there is a small issue with the 'FileField' module. When a CCK field of this type is associated with a content type, the following warning message is displayed on the confirmation screen.

warning: Invalid argument supplied for foreach() in /media/storage/www/drupal6/sites/all/modules/filefield/filefield_widget.inc on line 472.

However, VBO does actually set the FileField CCK field to the specified value.

2. Changing the node author field doesn't seem to work. I tried with and without creating new revisions, etc. The "new author" also has admin rights, so I don't think it's a permissions thing. No errors or warnings were displayed or logged.

3. Weirdness with Body field (see screenshot). The WYSIWYG editor for the body field shows up in the 'Code' column. The 'input format' is a separate row with another text field. You might want to look at that a bit.

4. You are probably tired of hearing from me on this subject; however, another feature request for you to ponder. With these changes, VBO can overwrite (CCK and non-CCK) fields with specified information. Which is awesome. However, when using multi-select fields in our environment, we often only want to add or remove particular selections based on some filter criteria. (Similar to Drupal's built-in capabilities to assign or remove new taxonomy terms.)

Either way, this will be a big help to us.

AttachmentSize
tmp.GIF 30.57 KB

#35

kratib - April 8, 2009 - 22:30

@stacy: glad it's finally working. Thanks a lot for hanging in there! I'll take a look at the issues you encountered. Can you please explain #4 again? I'm afraid I didn't get what you're trying to achieve. An example might help :-)

#36

stacysimpson - April 9, 2009 - 13:24

kratib, Re: Feature Request Q. The current implementation allows contributors to blast or overwrite fields without regards for the current value of those fields. This is a valued and needed feature, even for multi-select fields.

However, on an on-going basis, many of our mass update requirements for multi-select CCK fields is to add and/or remove only a single selection without modifying the existing selected values.

There are two built-in examples of this in Drupal and one theoretical example below:
1. Add or Removing Taxonomy values in the content management interface. (see screenshot)
2. Add or Remove roles in the built-in user management interface. (see screenshot)
3. Completely made up scenario below.

Complete range of possible values: Apples, Bananas, Oranges, Strawberries

Before:
Node #1 - Likes fruit:
- Apples
- Oranges

Node #2 - Likes fruit:
- Apples
- Bananas

I want to add 'Strawberries' as a selection to both of these nodes, but leave the other values intact.

Node #1 - Likes which fruit:
- Apples
- Oranges
- Strawberries

Node #2 - Likes which fruit:
- Apples
- Bananas
- Strawberries

This will be difficult to do with the current implementation because I can only overwrite all the selected values for the multi-select field.

Seems like the 'Action View' module had a configuration option within the view to merge or overwrite selected values for multi-select fields, but I don't remember exactly how it worked. Unfortunately, we've already whacked our D5 installation.

As a non-SME, I suppose you could add 2 new, distinct VBO actions for adding or removing values for multi-select fields only. When saving the modified value(s), merge the new selections (either adding or removing) with the field's existing values.

Hope this makes sense.

AttachmentSize
tmp.GIF 13.11 KB

#37

kratib - April 9, 2009 - 20:23

Re: Multiple values: got it now. I'll think of a clean way to add it to the field action.

Concerning the other issues:
1) Filefield warning: that's a tricky issue that will require significant work. Currently, what this warning means is that field validation is not occurring for filefields.
2) Changing the node author: I just committed a fix to resolve that issue.
3) a) Which WYSIWYG editor are you using? FCKEditor 6.x-1.3 did not behave this way.
b) Input format in a separate row: fixing this would require extensive work and I don't think it's worth it. For now, this minor annoyance will remain.

#38

stacysimpson - April 13, 2009 - 16:54

kratib, we are actively evaluating other WYSIWYG editors because FCK seems to be a bit buggy (although we currently use FCK in our production environment). The editor we are currently looking at: http://drupal.org/project/wysiwyg. NOTE: The WYSIWYG editor only displays in the 'Code' column for the 'Body' field. It displays appropriately in the 'Field' column for other CCK text fields.?.?

No worries on the 'Input format' quirk.

#39

patchak - April 15, 2009 - 14:11

Hey there Kratib :

Sorry for the delay on this issue, I was really busy but now came back to this problem..

As per your comment on no.23 here is the debug I get for my error :

I'm not sure if that helps you or not, but these fields are not all the ones I entered in my view.

string(20) "field_membres_relies" string(25) "field_membre_comite_apres" string(19) "field_statut_membre" string(15) "field_agence_cp" string(9) "field_nom" string(12) "field_prenom" string(15) "field_politesse" string(11) "field_notes" string(11) "field_canal" string(26) "field_contact_projet_relie"

Fatal error: Unsupported operand types in /home/blogsurf/sites/intranet/sites/all/modules/views_bulk_operations/fields.action.inc on line 52

I'm using latest dev build, not sure what would be causing this issue, I do have one custom cck field type in my site, based on nodereference code...

Thanks for any help, I really need this feature to manage a content import that went wrong ;)

Patchak

#40

kratib - April 21, 2009 - 21:25

@patchak: is field_contact_projet_relie your custom field? If so, can you please post the code for it?

#41

patchak - April 23, 2009 - 11:12

Hey there, thanks for the answer! Attached is my custom cck field that is based on nodereference field, it just adds a "meta" field to the nodereference so users can leave a comment.

Patchak

AttachmentSize
nodereference_meta-5.tgz 142 bytes

#42

Dimm - May 1, 2009 - 11:57

For D5 :
The 'Action Views' module, http://drupal.org/project/action_view
Allows you to edit multiple cck fields at once.

+ It need patch:
http://drupal.org/node/244439

#43

mattgilbert - May 1, 2009 - 15:18

subscribe

#44

kratib - May 1, 2009 - 16:47

@patchak: I didn't have time last week to look at your custom field. However, it seems the package you sent contains a zero-byte file. Can you please check and re-upload?

#45

mikeytown2 - May 27, 2009 - 01:41
Status:needs review» needs work

Get the same error

Skipping the fields works...

    if (($field['field_name'] != 'field_referrers') && ($field['field_name'] != 'field_testimonials')  && ($field['field_name'] != 'field_dimensions')) {

http://drupal.org/project/nodereferrer
http://drupal.org/project/computed_field

Computed Field

<?php
//Set Temp Variables
$temp_length_ft = '';
$temp_length_in = '';
$temp_length_in_fraction = '';
$temp_width_ft = '';
$temp_width_in = '';
$temp_width_in_fraction = '';
$temp_height_ft = '';
$temp_height_in = '';
$temp_height_in_fraction = '';
$temp_lwh_array = array();

//Compute length
if ($node->field_length[0]['value'] != '') {
   
$temp_length_ft = $node->field_length[0]['value']  . '';
    if (
$node->field_length_inches_fraction[0]['value'] != '') {
       
$temp_length_in_fraction = '&nbsp;' . $node->field_length_inches_fraction[0]['value']  . '&quot;';
        if (
$node->field_length_inches[0]['value'] != '') {
           
$temp_length_in = '&ndash;' . $node->field_length_inches[0]['value'];
        }
    }
    else if (
$node->field_length_inches[0]['value'] != '') {
       
$temp_length_in = '&ndash;' . $node->field_length_inches[0]['value']  . '&quot;';
    }
    else {
       
//$temp_length_in = '0&quot;';
   
}
   
$temp_lwh_array[] = 'L:' . $temp_length_ft . $temp_length_in . $temp_length_in_fraction;
}

//Compute width
if ($node->field_width[0]['value'] != '') {
   
$temp_width_ft = $node->field_width[0]['value']  . '';
    if (
$node->field_width_inches_fraction[0]['value'] != '') {
       
$temp_width_in_fraction = '&nbsp;' . $node->field_width_inches_fraction[0]['value']  . '&quot;';
        if (
$node->field_width_inches[0]['value'] != '') {
           
$temp_width_in = '&ndash;' . $node->field_width_inches[0]['value'];
        }
    }
    else if (
$node->field_width_inches[0]['value'] != '') {
       
$temp_width_in = '&ndash;' . $node->field_width_inches[0]['value']  . '&quot;';
    }
    else {
       
//$temp_width_in = '0&quot;';
   
}
   
$temp_lwh_array[] = 'W:' . $temp_width_ft . $temp_width_in . $temp_width_in_fraction;
}

//Compute height
if ($node->field_height[0]['value'] != '') {
   
$temp_height_ft = $node->field_height[0]['value']  . '';
    if (
$node->field_height_inches_fraction[0]['value'] != '') {
       
$temp_height_in_fraction = '&nbsp;' . $node->field_height_inches_fraction[0]['value']  . '&quot;';
        if (
$node->field_height_inches[0]['value'] != '') {
           
$temp_height_in = '&ndash;' . $node->field_height_inches[0]['value'];
        }
    }
    else if (
$node->field_height_inches[0]['value'] != '') {
       
$temp_height_in = '&ndash;' . $node->field_height_inches[0]['value']  . '&quot;';
       
    }
    else {
       
$temp_height_in = '&ndash;'.'0&quot;';
    }
   
$temp_lwh_array[] = 'H:' . $temp_height_ft . $temp_height_in . $temp_height_in_fraction;
}

$node_field[0]['value'] = implode('&nbsp;x&nbsp;', $temp_lwh_array);
?>

#46

doc2@drupalfr.org - June 26, 2009 - 22:44

Oh yes, please add this feature! And backport for d5...
We are a few d5ers who badly need this feature since editablefields doesn't seem regularly maintained...

In my case, editablefields doesn't work anymore for date v.2. It had been working with date v.1 but having it hacked for bulk update...
Quite a stake to get a CCK bulk update feature in VBO! But what a feature!

Best wishes towards the development of this feature. Kind regards, Arsène

#47

kratib - June 27, 2009 - 03:25

@doc2: The action "Modify node fields" is already functional on D6, but I doubt I'll have the time/energy to backport it to D5. I can help someone else to do it though...

#48

Aren Cambre - July 11, 2009 - 19:36

This issue has wandered a lot, so I am not clear it's addressing the essential need of bulk editing CCK fields with VBO. Also, I am having a problem with the PHP code way of editing, which appears to not be the focus of this issue. I have therefore opened #516560: Doesn't bulk edit CCK fields with PHP to document my problem.

#49

kratib - August 3, 2009 - 05:25
Status:needs work» fixed

Marking this feature a fixed. Please open separate issues for specific problems you might find.

#50

System Message - August 17, 2009 - 05:30
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.