showing the sum of field values

More
11 years 7 months ago - 11 years 7 months ago #41744 by days of summer
hi
i have a question and i hope you can help me

if i have a field named "number of students in the class "
and each article has details about certain class

are there a method that show the sum of the number of students in all classes ?

in other words
if i have afield with these details

field name : number of students
field value : 10 "or any other number"

can i have a code that show the sum of all values written in all articles of this field ?

i hope that i explained it clearly
thanks :)
Last edit: 11 years 7 months ago by days of summer.

Please Log in or Create an account to join the conversation.

More
11 years 7 months ago #41758 by ggppdk
Hello

you can edit category_items.php (or category_items_html5.php) of your custom FLEXIcontent template

components/com_flexicontent/templates/MyCustomTemplate/category_items.php

and your custom code at the end of this file


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

Please Log in or Create an account to join the conversation.

More
11 years 7 months ago #41762 by days of summer
thanks Mr. ggppdk for replying
i tried to put that code in the file
but it doesn't appear

can you please tell me the appropriate code
for displaying that sql in side category template ?
Code:
SELECT field_id, SUM(value) FROM j25_flexicontent_fields_item_relations WHERE field_id = 23 GROUP BY field_id

the goal of that sql is to
show the sum of field values in the category

thanks

Please Log in or Create an account to join the conversation.

More
11 years 7 months ago #41777 by ggppdk
Hello

this question maybe useful to others, so i have made a FAQ article:

Example of calculating an aggregated field value for the items assigned to a category


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

Please Log in or Create an account to join the conversation.

More
11 years 7 months ago #41791 by ggppdk
Hello

code highlighting needs to be setup in new flexicontent.org

[edit: i have corrected the code below, just set a correct field id]

please recopy code from the FAQ article and change the
$field_id to be the id of you field.

if you paste it inside PHP code, then remove the starting <?php and the trailing ?>

Regards


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

Please Log in or Create an account to join the conversation.

More
11 years 7 months ago #41811 by days of summer


thanks Mr ggppdk for helping me
it is now working

but i have another question please
what if i wanted to show the sum of values of two or more fields ?

i should edit the
Code:
$field_id = 15; // CHANGE THIS !!!

or what should i do ?

thanks again

Please Log in or Create an account to join the conversation.

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.412 seconds
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Display
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline
Save