function fb_social_handler_field::render in Facebook social plugins integration 7.2
Same name and namespace in other branches
- 6.2 plugins/views/fb_social_handler_field.inc \fb_social_handler_field::render()
Implements views_handler_field#render().
Overrides views_handler_field::render
File
- plugins/
views/ fb_social_handler_field.inc, line 48 - Provide views handler for Facebook Social plugins.
Class
- fb_social_handler_field
- A handler to provide a field for Facebook Social plugins.
Code
function render($values) {
if (!empty($this->options['fb_social_plugins'])) {
$presets = fb_social_get_presets();
$preset = $presets[$this->options['fb_social_plugins']];
$type = $presets[$this->options['fb_social_plugins']]->plugin_type;
$url = NULL;
// Only supply url for node if nid exists and FB preset accepts url.
// TODO: instead of hardcoded values, get this info from plugin defaults
if ($type == 'like' || $type == 'send' || $type == 'facepile' || $type == 'comments') {
// TODO: with a little work this could be expanded to other entities.
if (!empty($values->nid)) {
$url = fb_social_url('node/' . $values->nid);
}
elseif (!empty($values->uid)) {
$url = fb_social_url('user/' . $values->uid);
}
$preset->fb_attrs['href'] = $url;
}
$value = fb_social_preset_view($preset);
}
return $value;
}