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.
I have a content type with an integer field. The integer has a prefix of $.
The fields display correctly in my view but the calc row (which totals them) does not display the prefix.
There are hacky ways to fix this but it would be ideal if the module respects field prefix/suffix.
Thanks !
Comment | File | Size | Author |
---|---|---|---|
#11 | views_calc-calc-row-prefix-suffix-1570746-11.patch | 4.09 KB | Morasta |
#6 | views_calc.patch | 3.33 KB | morenstrat |
Comments
Comment #1
KarenS CreditAttribution: KarenS commentedThis sounds easy but is not. We can't run an arbitrary value through the formatter that adds these things. I'll make this a feature request in case some one can figure out a way to make it work and provide a patch. But I couldn't see a way to do it.
Comment #2
_paul_meta CreditAttribution: _paul_meta commentedUnderstandable. As an alternative, is there any chance to set a custom prefix / suffix for each calc field ?
Comment #3
KarenS CreditAttribution: KarenS commentedThat's probably the only way this can work. Do you want to supply a patch?
Comment #4
_paul_meta CreditAttribution: _paul_meta commentedUnfortunately i am not a sufficiently experienced drupal developer to make such a patch.
Comment #5
quickly CreditAttribution: quickly commentedI am having a similar issue.... my integer field has % sign at its end... views calc does not perform aggregation on it at all..
Comment #6
morenstratThis patch allows for setting a custom prefix/suffix for each column that has a calc field.
Comment #7
kietnguyen CreditAttribution: kietnguyen commentedThank to dunix for the patch. It works but instead of respecting to the fields' prefixes and suffixes, you have to set the prefix and suffix for each column in Settings of Views Calc Table.
Comment #8
Exploratus CreditAttribution: Exploratus commentedThanks. Works great!
Comment #9
j.johnson.bbt CreditAttribution: j.johnson.bbt commentedWorks great. Anyway to add a field for moving the decimal also?
When working with prices, it automatically moves the decimal over 2 so 10000 becomes $100.00 etc.
Then when I run it through the table, the output changes it back to 10000. If I put the dollar sign in front, I'm still stuck with $10000.
Comment #10
Morasta CreditAttribution: Morasta commented#6 patch worked for me but wouldn't apply to the latest dev update (2014-Mar-25). I have attached an updated patch that works with that dev version.
Comment #11
Morasta CreditAttribution: Morasta commentedNewer patch from #10 that fixes some warnings from the previous one.