OrdaSoft forum
Welcome, Guest
Please Login or Register.    Lost Password?
php code field "php show" (0 viewing) 
Go to bottom Favoured: 0
TOPIC: php code field "php show"
hansel (User)
Gold Boarder
Posts: 232
graphgraph
User Offline Click here to see the profile of this user
php code field "php show" 7 Months ago
Karma: 0  
I want to compare the current value of the select list text to let a field be displayed or not

if({|text_select_list_172|}[0]->data == '["0"]' ) {
return false;
}
else {
return true;
}

This code doesn't work. What is the correct code?

If I let the content show of the current select list text {|text_select_list_172|}[0]->data
with
echo({|text_select_list_172|}[0]->data);
I get ["0"]
Logged Logged
Last Edit: 2022/05/04 19:32 By hansel.
The administrator has disabled public write access.
admin (Admin)
Admin
Posts: 7848
graph
User Offline Click here to see the profile of this user
Re:php code field "php show" 7 Months ago
Karma: 96  
Hello

in Joomla CCK as hint for work with Custom Field -> PHP, you need click at "field" settings There you will see mask for all fields wit style and without styles, This may help to you duplicate or show some field exactly as you need.

so next if you see some field mask: {|text_select_list_172|}

all what you need do , the write below code:
Code:

print_r({|text_select_list_172|})


so you will can check this field inner data format. After you easy write IF condition

And please use "print_r" - this command help to you see DATA format, but "echo" move all data to "STRING" format

Regards
OrdaSoft team
Logged Logged
Last Edit: 2022/05/06 07:30 By admin.
The administrator has disabled public write access.
VlaDOS (Admin)
Admin
Posts: 118
graphgraph
User Offline Click here to see the profile of this user
Re:php code field "php show" 7 Months ago
Karma: 2  
Hello,
As I wrote before, the select field is more complex for this type of operation. The correct code would look like this:
Code:


$temp_val = json_decode({|text_select_list_172|}[0]->data);
if($temp_val[0] ==  '0') {
   return false;
}else {
   return true;
}

Logged Logged
The administrator has disabled public write access.
Go to top