How to display a column in which the sum of the two other columns in CCv6?

Twickbot 15 May, 2017
I have 2 columns in MySQL table:
column1, column2

How to display a column "total" in which the sum of this columns in CCv6?

In MySQL it will be:
SELECT column1, column2, (column1 + column2) as total FROM table_name;

Is it possible in CCv6?

And give me pls link to good documentation.
I didn't find it.

Thank you.
Max_admin 16 May, 2017
Hi Twickbot,

In the "Columns views" you will need to add this:

Model.field_total:{fn:php_function_name}

Then add a "php" function and set the name to "php_function_name", then add this code:

echo $this->get("table_view_name.row.Model.field_1") + $this->get("table_view_name.row.Model.field_2");


Unfortunately there is only 1 tutorial for v6 at the moment and its in the FAQs section, I'm trying to add more so hopefully soon.

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Twickbot 16 May, 2017
Thx for answer but I could not make it work.

My settings:

Views - Table20

Data provider:
{var:stat_summary}


Columns list:
cloak_stat_summary.column1:Column1
cloak_stat_summary.column2:Column2


As u said, I add to Columns views:
Model.field_total:{fn:php16}


Functions - php16:
echo $this->get("table_view_name.row.Model.field_1") + $this->get("table_view_name.row.Model.field_2");


Result:
Table still show only 2 colums: Column1 and Column2.
Column "Total" did not appear.
What did I do wrong?
Max_admin 16 May, 2017
Answer
Hi Twickbot,

You need to define the column in the columns list or it will not appear:

cloak_stat_summary.total:Total

Columns views:

cloak_stat_summary.total:{fn:php16}

PHP:

echo $this->get("Table20.row.cloak_stat_summary.column1") + $this->get("Table20.row.cloak_stat_summary.column2");


Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Twickbot 16 May, 2017
Tnank u for answer.
It's much better now.
Appeared the third column. But, it is filled with zeros.
What else do I need to correct to get the sum of the first two columns in the third column?
Twickbot 16 May, 2017
1 Likes
Yes!!!
Now it's working.
After I changed the table name from "Table20" to "table20" in PHP code.
Thanks again.
This topic is locked and no more replies can be posted.