PHP - Can't understand this code. -
i have code here on website i've taken on , can't head around it.
could please explain me going on. have knowledge of php baffles me.
thanks
function decawave_preprocess_field(&$vars) { if($vars['element']['#field_name'] == "field_resource_public_pdf" || $vars['element']['#field_name'] == "field_resource_pdf") { $vars['items'][0]['#disclaimer'] = !empty($vars['element']['#object']->field_disclaimer) ? $vars['element']['#object']->field_disclaimer[language_none][0]['value'] : 0;} }
if value of $vars['element']['#field_name']
equal (note type juggling here) 'field_resource_public_pdf'
or $vars['element']['#field_name']
equal (type juggling again) "field_resource_pdf"
string following:
execute empty($vars['element']['#object']->field_disclaimer)
(doc this function) function, if returns false, assign value of $vars['element']['#object']->field_disclaimer[language_none][0]['value']
$vars['items'][0]['#disclaimer']
. otherwise (if [empty][2]($vars['element']['#object']->field_disclaimer)
returns true, assign 0
$vars['items'][0]['#disclaimer']
.
the code pretty straightforward, i'd note function written poorly.
Comments
Post a Comment