function isotope_views_helper_get_field_value in Isotope (with Masonry and Packery) 7.2
Helper function to get a field value.
@todo: this seems very messy - there must be a better way to do it?
Parameters
object $entity: The entity.
string $fieldname: The field name.
Return value
string Value.
2 calls to isotope_views_helper_get_field_value()
- template_preprocess_isotope_views_filter in isotope_views/
isotope_views.theme.inc - Preprocess function to build isotope filter blocks.
- template_preprocess_isotope_views_grid in isotope_views/
isotope_views.theme.inc - Preprocess function to build the isotope grid.
File
- isotope_views/
isotope_views.theme.inc, line 99 - Theme callbacks.
Code
function isotope_views_helper_get_field_value($entity, $fieldname) {
if (!empty($entity->{'field_' . $fieldname})) {
foreach ($entity->{'field_' . $fieldname} as $a) {
if (!empty($a['rendered'])) {
$field[] = render($a['rendered']);
}
}
}
elseif (!empty($entity->{'taxonomy_term_data_' . $fieldname})) {
// Term title is not a real field in D7.
$field[$fieldname] = $entity->{'taxonomy_term_data_' . $fieldname};
}
elseif (!empty($entity->{'node_' . $fieldname})) {
$field[$fieldname] = $entity->{'node_' . $fieldname};
}
if (isset($field)) {
$r = array();
if (!is_array($field)) {
$field = array(
$field,
);
}
foreach ($field as $f) {
$filter_value = render($f);
$r[] = trim(check_plain(strip_tags($filter_value)));
}
return $r;
}
return '';
}