cc5: PHP code in table body?

How to use PHP code for conditional formatting in CC5 table display.

Overview

The issue occurs when migrating from CC4, where PHP code in custom list body no longer works in CC5's HTML settings.
Use the 'PHP functions' box in the front/admin listing area, defining the field name and using $cell or $row variables to apply formatting based on field values.

Answered
bm bmarkus 30 Mar, 2015
Hi,

in CC4 I'm using PHP code in custom list body, changing background color, italic, bold, etc. based on field value. Tried PHP code in CC5 Table display mode HTML setting but didn't work. OK, it is a HTML setting.

PHP functions use is not clear for me. Can someone provide a practical example?

Thanks... Béla

P.S: I'm just trying migraete from CC4 to CC5, there are many attractive new features but differences too.
Max_admin Max_admin 30 Mar, 2015
Answer
1 Likes
Hi Béla,

You can use the "PHP functions", here is how it works:

You define the field name first then write the function return:

Model.field:return "xyz";


You can use the variable "$cell" to get the value of that field, or the variable "$row" to get any value of any field in that row:
$row["Model"]["field"]


Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
bm bmarkus 31 Mar, 2015
Thanks Max, works as expected.

Béla
ne nemesyssoft 12 Apr, 2015

Hi Béla,

You can use the "PHP functions", here is how it works:

You define the field name first then write the function return:

Model.field:return "xyz";


You can use the variable "$cell" to get the value of that field, or the variable "$row" to get any value of any field in that row:
$row["Model"]["field"]


Regards,
Max



That's interesting but where to do you define this? There are a ton of various settings for a CC connection. I'm lost.
Max_admin Max_admin 12 Apr, 2015
In the "PHP functions" box under the front/admin listing area.

You should check the tutorials under FAQs > CCv5 first

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.