Data displayed in the table view with if statement
Posted: 2020-08-30 20:48
Hello all,
I'm rather new to php. I wanted to modify the Appgini example replacing a rating with a star icon (https://bigprof.com/appgini/tips-and-tu ... eview-data). What I wanted to do is selecting the image with an if/elseif/else Statement.
My code is below. I guess it's not correct comparing it in this way: $ReqStatus = "New" but why? And what would be an appropirate way?
For testing I assigned the Value "New" to $ReqStatus it works. Any help appreciated.
I'm rather new to php. I wanted to modify the Appgini example replacing a rating with a star icon (https://bigprof.com/appgini/tips-and-tu ... eview-data). What I wanted to do is selecting the image with an if/elseif/else Statement.
My code is below. I guess it's not correct comparing it in this way: $ReqStatus = "New" but why? And what would be an appropirate way?
For testing I assigned the Value "New" to $ReqStatus it works. Any help appreciated.
Code: Select all
function itm_requirements_init(&$options, $memberInfo, &$args) {
// get the original fields array
$oldFields = $options->QueryFieldsTV;
// loop through all fields
foreach($oldFields as $field => $title){
// find the field that we need to customize
if($field == '`itm_requirements`.`requirement_status`'){
// apply custom SQL formatting to the field
$ReqStatus = '`itm_requirements`.`requirement_status`';
// $ReqStatus = "New";
// the row below seems not to be a correct comparison. But why?
if ($ReqStatus == "New") {
$modField = "CONCAT('<img src=\"hooks/','icon1','.png\" border=\"0\" />')";
$newFields[$modField] = $title;
} else {
$modField = $ReqStatus;
$newFields[$modField] = $title;
}
}else{
// for other fields, keep them unchanged
$newFields[$field] = $title;
}
}
// now apply the modified fields
$options->QueryFieldsTV = $newFields;
return TRUE;
}