We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

totaling the value of a custom field...

Development and Programming

Stephen Slater's avatar
Stephen Slater
366 posts
16 years ago
Stephen Slater's avatar Stephen Slater

Hello all,

Does anyone know if there is a plugin that will total the value of a custom field? For my use, I’d need the plugin to filter based on author_id and status.

Does it already exist?

Thanks in advance!

Stephen

       
Adrienne L. Travis's avatar
Adrienne L. Travis
213 posts
16 years ago
Adrienne L. Travis's avatar Adrienne L. Travis

No, but you could do this really easily using the query module. You’ll need to know the actual field_id number of your custom field, then try something like this (INSIDE your exp:weblog:entries loop):

{exp:query sql="SELECT SUM(field_id_999) AS mytotal 
FROM exp_weblog_data, exp_weblog_titles 
WHERE exp_weblog_data.entry_id = exp_weblog_titles.entry_id 
AND author_id = '{author_id}' AND status = '{status}';"}

The total is: {mytotal}

{/exp:query}

If you just need a static author and status, you can use it OUTSIDE your exp;weblog:entries loop, and just hard-code those values (author_id = ‘12’ AND status = ‘open’, for example).

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.