Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Let's add some useful and easy to implement text processing capabilities:
- convert to upper / lower case
- trim string
- strip tags
- encode / decode html entities
- reverse text
- sort & reverse sort lists (numerically and alphabetically)
Original issue:
Sometimes I only need aliases for a few content types, but I don't want the overhead and full fledged features of the pathauto module. Creating a rule to make path aliases is pretty painless, but I was wondering if it is or would be possible to transform the aliases to lowercase in the rules. At this time, it only seems possible to use the case of the node title.
Comment | File | Size | Author |
---|---|---|---|
#17 | rules_data_transforms-capitalization-1-1.patch | 1.72 KB | tr33m4n |
#14 | transform_text.patch | 12.91 KB | mitchell |
#12 | rules_data_transforms-7.x-1.x-dev.tar_.gz | 8.85 KB | mitchell |
Comments
Comment #1
mitchell CreditAttribution: mitchell commentedBumping feature request to 7.x.
Judging by fago's comment in #852596: Port path module integration, this'll probably be easier with pluggable path cleaners.
Comment #2
fagoIndeed. Maybe we could add a textual data processor doing that? We could also offer some other simple text processing options like strip html tags.
Comment #3
fagoSuggestions for other useful and easy to implement text processing capabilities are welcome. So far I think
* make lower/uper case
* ucfirst char
* strip html tags
would be useful.
Comment #4
fagobump. We still need that.
Comment #5
mitchell CreditAttribution: mitchell commentedA very similar set of functionality is currently available to Feeds through its preprocessing hook in an extension, called Feeds Tamper. Here is a link to all the text processors which will be easy to port and will work very well in a generalized fashion: http://drupalcode.org/project/feeds_tamper.git/tree/refs/heads/7.x-1.x:/...
Comment #6
mitchell CreditAttribution: mitchell commentedComment #7
mitchell CreditAttribution: mitchell commentedMarked #1323056: Calculations and Rounding as a duplicate.
Rounding is basically trim, I think.
Comment #8
mitchell CreditAttribution: mitchell commentedSome long overdue code can be found in Rules Data Transforms. I originally intended to have this code posted here as a patch, but that'll be next on my list. In any event, @maintainers, please review the code and let me know if there's anything specific that needs to be changed in order to have it merged and if a separate project is necessary in your minds.
Comment #9
mitchell CreditAttribution: mitchell commentedRe: #7. I was wrong. Rounding is a separate function. Added #1371492: Rounding to rules_data_transforms.
Comment #10
mitchell CreditAttribution: mitchell commentedTransformation seems a bit more refined over processing.
Comment #11
AndrzejG CreditAttribution: AndrzejG commented@Mitchell - please update dev of Your module, to include this Rounding function.
Comment #12
mitchell CreditAttribution: mitchell commentedUploading a tar.gz of requested code. If someone else can help by reviewing the code and submitting a patch, I would really appreciate it. Coding isn't my expertise, and I've already done quite a bit to produce this.
Known bug: #1429076: Action: 'make uppercase' doesn't work.
See also, Issues tagged 'data transforms' for more related code improvements and use cases.
Comment #13
freddura CreditAttribution: freddura commentedFor the action "combine list into string" it would beneficial to be able to select a multi-value field as a list option from within the data selector. For example, if a have a multi-value integer field titled "field-integer-list" which resides in the node being viewed, then I should be able to select that integer list directly from within the data selector by typing in and receiving a match: "node:field-integer-list." Instead I receive a match: "node:field-integer-list:" When I change the match to "node:field-integer-list" and click save, I receive an error message: "The data type of the configured argument does not match the parameter's input_list requirement."
Look forward to this patch being committed to the rules module nevertheless. Thanks!
Comment #14
mitchell CreditAttribution: mitchell commentedHere's a patch with the functions listed in the issue summary:
Current Bugs
The code does work.
drush dl rules_data_transforms
will get you up and running. The patch is mainly here to illustrate where the code might go and how it might look.@fago, what do you think of the coding style and organization? I don't like adding a second file, like I did here, but organizing it as you did in data.eval.inc and data.rules.inc is a bit difficult. I started #1540394: Make Data API's module integrations pluggable to address this in a way that will deal with the other data related patches.
Side note: I had really hoped that by renaming rules_data_transforms.rules.inc to data_transforms.rules.inc and putting it Rule's modules dir, it would work. The file and function names seemed to align, but I cleaned my cache and was not so lucky, so I'm interested to find out why it didn't work.
Comment #14.0
mitchell CreditAttribution: mitchell commentedupdate
Comment #15
mitchell CreditAttribution: mitchell commentedI removed 'implode & explode lists', 'combine lists', and 'permute lists' from this issue, because they fit better in another.
Also, 'convert string to date' is also addressed in #1301022: Action: type conversion for numbers, integers, and strings. It's better suited there.
Comment #16
mitchell CreditAttribution: mitchell commentedIn order to get this to a review-able state, this patch needs to be rewritten to extend data.rules.inc and data.eval.inc. I will see if can handle the port in the next few days, but if I don't post anything with a week, consider me unassigned.
I really want to see this go in soon, but if you do to, then trust me... you're coding skills are better than mine.
Comment #17
tr33m4n CreditAttribution: tr33m4n commentedI posted this on the rules data transform module page, thought I'd post it here as well. Attached a patch that allows first word only capitalization or capitalization of every word in the string.
Cheers
Comment #18
dmoonman CreditAttribution: dmoonman commentedComment #19
klonosThanx for bumping this Derek ;)
Comment #19.0
klonosa
Comment #20
mjcarter CreditAttribution: mjcarter commentedThe rules_data_transforms module has existing features and number of patches waiting to be committed adding features which aren't specifically related to text handling - things like unserializing data and converting from one array type to another.
At the moment the module is marked as a temporary code location for things related to this issue.
My thoughts are that rules_data_transforms may contribute more to the community by remaining a separate module which handles all advanced data manipulation not carried out by rules itself, sort of equivalent to the feeds_tamper module's relation to feeds - particularly in light of the lack of progress on this issue.
What are others thoughts on this?
Comment #21
sonicthoughts CreditAttribution: sonicthoughts commentedStumbled on this - exactly what I'm looking for but totally hidden! Biggest reason to add to Rules as a submodule is so people know it exists!
Comment #22
jelo CreditAttribution: jelo commentedCould the maintainers clarify what the approach going forward is going to be, e.g. integration into rules, sub-module of rules or separate module? I find these additional actions very useful. Unfortunately, Rules Data Transform at https://www.drupal.org/project/rules_data_transforms is only in dev and still states it is temporary while this discussion started more than 4 years ago. The functionality seems to be working though...
Thanks!
Comment #23
thePanz CreditAttribution: thePanz at Liip for FREITAG lab. AG commentedI would also add my module: https://www.drupal.org/sandbox/thepanz/rules_list_extra to the list.
It focuses on lists, the first action supported is "merge list", and I am planning to add further functions.
Support and help needed, or could it be better to integrate it with rules_data_transform module?
Comment #24
dercheffeIMHO a very important feature. +1