Skip to content

Instantly share code, notes, and snippets.

@leanderlindahl
Last active August 26, 2015 10:55
Show Gist options
  • Save leanderlindahl/62dcc02d90bd7ff4d7aa to your computer and use it in GitHub Desktop.
Save leanderlindahl/62dcc02d90bd7ff4d7aa to your computer and use it in GitHub Desktop.
<?php
function exposedfilter_buttons_form_alter(&$form, &$form_state, $form_id) {
/**
* Manipulate output of Views Ajax Exposed filter
*/
if ($form['#id'] == 'views-exposed-form-exposed-filter-example-block') {
$form['#attached']['js'] = array(
drupal_get_path('module', 'exposedfilter_buttons') . '/js/exposedfilter_buttons.js',
);
$links = $form['field_kategori_tid']['#options'];
$newlinks = array();
foreach ($links as $tid => $term_name) {
if ($tid == 'All') {
$newlinks[] = array('data' => '<span class="filter-tab"><a href="" id="' .$tid . '" class="active">' . $term_name . '</a></span>', 'class' => array('pop-filter-label'));
}
if (_get_term_depth($tid) == 1) {
$newlinks[] = array('data' => '<span class="filter-tab"><a href="" id="' .$tid . '">' . $term_name . '</a></span>', 'class' => array('pop-filter-label'));
}
}
$prefix = theme(
'item_list', array(
'items' => $newlinks,
'type' => 'ul',
'attributes' => array('id' => 'pop-filter-list'),
'container_id' => 'scope-list-wrapper',
));
$form['links'] = array(
'#type' => 'markup',
'#value' => $prefix,
'#markup' => $prefix,
);
}
// extra submit form handle
$form['#submit'][] = 'exposedfilter_buttons_form_submit';
}
// handle form submition
function exposedfilter_buttons_form_submit($form, &$form_state){
$values = $form_state['values'];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment