Hello,
I recently was working on a project that needed Search and Replace functionality on node fields through VBO. The modify node fields wasn't quite enough because that only allowed the user to change the entire value of a field rather than just a part of it. I created a module to define the action and it works pretty well. I was going to post the module as a project, but felt that I should check here to see if you would be willing to integrate a search and replace action into VBO. I think it would be better to integrate it rather than throw another module into the mix. I've attached the action which is properly formatted for quick integration. You should be able to just drop the file into the views_bulk_operations module root and give it a test.
Here are some of the features:
- Configuration options on the VBO views config page to choose field selection widget and to exclude certain fields (just like modify node fields)
- Field list for search and replace is dynamically generated to only offer fields that are available in the currently selected node (also, just like modify node fields)
- Users can search one or some or all of the fields at a time
- Support for search prefixes and suffixes to create advanced searches
- Options for case sensitivity and exact matches
Thanks for your time!
| Comment | File | Size | Author |
|---|---|---|---|
| #14 | search_and_replace.action.inc_.zip | 4.36 KB | drclaw |
| #1 | search_and_replace.action.inc_.zip | 3.7 KB | drclaw |
| search_and_replace.action.inc_.zip | 3.73 KB | drclaw |
Comments
Comment #1
drclaw commentedSorry left a couple dpms in there! Here's a better file.
Comment #2
giorgio79 commentedFantastic. This could replace the Search and Replace Scanner module: http://drupal.org/project/scanner
Can this action do regular expression search and replace as well?
Comment #3
drclaw commentedNot yet, but that could easily be built into it, I think...
Comment #4
giorgio79 commentedGreat, started directing people over here: #1159944: Update Search and Replace to D7 - And Some Alternatives
Comment #5
infojunkieCan someone please review this action and post feedback?
Comment #6
giorgio79 commentedJust tested it, it is pretty good.
Few issues:
1. Noticed a dpm line here
Called from /sites/all/modules/views_bulk_operations/search_and_replace.action.inc, line 21
2. Also noticed, that only CCK fields are offered for selection, would be great to have node title and body as well in the fields list.
Comment #7
drclaw commentedGlad to see someone is interested in this!
I'm a bit of a dpm bandit, sorry about that. =P
Getting the title and body in there should be no problem, and I agree that it would be useful. I'll take a look at that and post a new patch soon
Comment #8
infojunkie@drclaw: if you plan to add support for non-CCK fields, I suggest you take a look at fields.action.inc because it uses a generic hook mechanism to handle arbitrary fields. You could use the same hook and augment it with information you need.
Comment #9
drclaw commented@infojunkie I actually used that action as a starting point but left that part out. I'll revisit it and see what I can do.
Comment #10
marcusx commentedcool stuff +1 from me
Comment #11
marcusx commentedWill this work for the D7 Version of VBO as well? I tried it, and I got no error but I also get no search and replace action in the vbo configuration either.
Comment #12
bojanz commentedNo. This code uses CCK, so it would need to be rewritten for D7 (and Field API).
Same reason why the D7 version of VBO still doesn't have the action to bulk modify fields, see #1057158: Provide an action for modifying entity values.
Comment #13
salah1drclaw,
How do you recommend for the code to be used meantime?
I'm new to Drupal and my only thinking is i put this into module and provide form for it to be used?
How should i test this in drupal site?
Comment #14
drclaw commentedI'm attaching the action again, this time with support for the title and body fields. I don't know how much time I will have in the next little while to support all arbitrary fields, but hopefully this helps some people out for now.
@m-abshir:
Download the file, and unzip it.
Comment #15
infojunkieComment #16
bojanz commentedNice work!
However, I think this action should live in its own module. That would give you direct access to improve it, and a faster way to provide support (as well as a D7 port).
My idea is to have only the most needed core actions in VBO, especially since the D6 branch is basically in maintenance mode.
Comment #17
drclaw commentedOkay, cool. Thanks for the info. I'll put it in a module. Just thought I'd check here first. =)
Thanks!
Comment #18
adam_b commentedsubscribe
Comment #19
jenlampton@drclaw would you please add a link to your module in this issue queue? :)
Comment #20
drclaw commentedSorry @jenlampton, I never created a module for it. =/
I'll get started on that ASAP and post a link here.
Comment #21
drclaw commentedIn case anyone is interested, I finally made a project for the vbo search and replace module. There's a D6 and D7 version. I just made a couple of dev releases but they're pretty stable. Some testing would be great so I can put out a full release. =)