View source
<?php
function test_theme() {
return array(
'views_fieldsets_simple' => array(
'views_fieldsets_label' => 'Super simple, func, no tpl',
'variables' => array(
'fieldset_fields' => array(),
'legend' => '',
),
),
);
}
function hook_views_fieldsets_views_field_options_alter(&$options, $handler) {
$options['link']['contains']['path'] = array(
'default' => '',
);
$options['link']['contains']['absolute'] = array(
'default' => 0,
);
}
function hook_views_fieldsets_views_field_form_alter(&$form, $handler) {
$form['link'] = array(
'#type' => 'fieldset',
'#title' => t('Link options'),
'#description' => t('To wrap the entire fieldset content with a link, enter a path.'),
);
$form['link']['path'] = array(
'#type' => 'textfield',
'#title' => t('Path'),
'#default_value' => $handler->options['fieldset']['link']['path'],
);
$form['link']['absolute'] = array(
'#type' => 'checkbox',
'#title' => t('Absolute'),
'#default_value' => $handler->options['fieldset']['link']['absolute'],
);
}
function template_preprocess_views_fieldsets_simple(&$variables) {
$variables['legend'] = 'OVERRIDE YO!';
$handler = $variables['fields'][$variables['fieldset_field']]->handler;
$path = $handler->options['fieldset']['link']['path'];
$path = $handler
->tokenize_value($path, $variables['view']->row_index);
$vars['href'] = url($path);
}
function theme_views_fieldsets_simple($variables) {
$content = implode("\n", array_map(function ($field) {
return $field->separator . $field->wrapper_prefix . $field->label_html . $field->content . $field->wrapper_suffix;
}, $variables['fieldset_fields']));
$html = '<fieldset>';
$html .= '<legend>' . check_plain(strip_tags($variables['legend'])) . '</legend>';
$html .= check_plain(strip_tags($content));
$html .= '</fieldset>';
return $html;
}