function npop_ds_render_field in Node pop-up 7
Placeholder for ds_render_field(), processing ds title links by npop.
Parameters
object $field: Field which need to render.
Return value
string rendered field html code.
1 string reference to 'npop_ds_render_field'
- npop_ds_fields_info_alter in ./
npop.module - Implements hook_ds_fields_info_alter().
File
- ./
npop.module, line 404 - Create popup nodes with ajax and Drupal core functionality.
Code
function npop_ds_render_field($field) {
$output = '';
$settings = isset($field['formatter_settings']) ? $field['formatter_settings'] : array();
$settings += $field['properties']['default'];
if ($field['entity_type'] !== 'node' || empty($settings['npop']) || empty($settings['link']) || $field['field_name'] !== 'title') {
return ds_render_field($field);
}
// Basic string.
if (isset($settings['link text'])) {
$output = t($settings['link text']);
}
elseif (isset($field['properties']['entity_render_key']) && isset($field['entity']->{$field['properties']['entity_render_key']})) {
if ($field['entity_type'] == 'user' && $field['properties']['entity_render_key'] == 'name') {
$output = format_username($field['entity']);
}
else {
$output = $field['entity']->{$field['properties']['entity_render_key']};
}
}
if (empty($output)) {
return '';
}
// Add use-ajax class for ajax processing.
$link_options = array(
'attributes' => array(
'data-npop' => array(
$field['entity']->nid,
),
),
);
if (!drupal_is_front_page() && npop_check_change_url($field['entity']->type)) {
$link_options['query']['parent'] = '/' . request_path();
}
$output = l($output, 'node/' . $field['entity']->nid, $link_options);
// Wrapper and class.
if (!empty($settings['wrapper'])) {
$wrapper = check_plain($settings['wrapper']);
$class = !empty($settings['class']) ? ' class="' . check_plain($settings['class']) . '"' : '';
$output = '<' . $wrapper . $class . '>' . $output . '</' . $wrapper . '>';
}
return $output;
}