By FuXXz on
Hello together,
I copied some code from handbook for adding "reset" button to exposed filter in views and one snippet for takes the form out of the table. If i use both together i get this error:
Fatal error: Cannot redeclare phptemplate_views_filters() (previously declared in .../template.php:296) in .../template.php on line 339
//function takes form out of table
---> LINE 296 function phptemplate_views_filters($form) {
if ($form['#view_name'] == 'comtecsuche') {
$view = $form['view']['#value'];
$form['submit']['#value'] = 'Search';
$rows_theme = '';
foreach ($view->exposed_filter as $count => $expose) {
$rows_theme .= '<div class="filter ' . $form["filter$count"]['#name'] . '">';
$rows_theme .= '<label for="' . $form["filter$count"]['#id'] . '">'. $expose['label'] .'</label>';
$rows_theme .= drupal_render($form["op$count"]) . drupal_render($form["filter$count"]);
$rows_theme .= '</div>';
}
$rows_theme .= '<div>'. drupal_render($form['submit']) .'</div>';
return drupal_render($form['q']) . $rows_theme . drupal_render($form);
}
else {
return theme_views_filters($form);
}
}
// function "reset" button
function phptemplate_views_filters($form) {
$view = $form['view']['#value'];
foreach ($view->exposed_filter as $count => $expose) {
$row[] = drupal_render($form["op$count"]) . drupal_render($form["filter$count"]);
$label[] = $expose['label'];
}
$form['reset'] = array(
'#type' => 'markup',
'#value' => '<input '. drupal_attributes(array('type' => 'button', 'value' => t('Reset') )) .'class="form-submit" onClick="window.location = \'' .url($view->url) .'\';" />',
'#weight' => 19,
);
$row[] = drupal_render($form['submit']) .drupal_render($form['reset']);
$label[] = ''; // so the column count is the same.
// make the 'q' come first
return drupal_render($form['q']) . theme('table', $label, array($row)) . drupal_render($form);
----> LINE 339 }
function phptemplate_views_summary_VIEWNAME($view, $type, $level, $nodes, $args) {
foreach ($nodes as $node) {
$item = views_get_summary_link($view->argument[$level]['type'], $node, $base);
}
$output = theme('links', ', ');
return $output;
}
Comments
You can't have the same
You can't have the same function declared twice. Each function name has to be unique.
Passing Phase Web Development
ohh tahnk you! But can
ohh thank you! But can anyone say how i combine this functions?
I'm not familiar with views
I'm not familiar with views filters but where you have if ($form['#view_name'] == 'comtecsuche') { in the first function you create another if condition and put the code for the reset button inside that (closed off with {}'s). I have no idea what value to use for $form['#view_name'] in your situation but that is the general direction you should be heading.
Passing Phase Web Development