Темизация Views Exposed Filter Form в Drupal 7


13:51, 16/03/2018

Вариант 1

Копируйте из модуля Views \views\theme\views-exposed-form.tpl.php к себе в тему sites/all/themes/YOUR_THEME/views-exposed-form--YOUR-VIEW-NAME.tpl.php.

Вариант 2

В template.php:

// Override Views Exposed Filter Form by tylerfrankenstein.com/node/125
function [YOUR_THEME]_form_alter(&$form, &$form_state, $form_id) {
	if ($form_id == 'views_exposed_form' && $form_state['view']->name == 'my_view_name' && $form_state['view']->current_display == 'my_view_display_name') {
		// Only show published nodes as options for the exposed filter.
		$sql = "SELECT nid, title FROM {node} WHERE status = 1 ORDER BY title ASC";
		$result = db_query($sql);
		$nodes = $result->fetchAll();
		$options = array('All' => '- Any -');
		foreach ($nodes as $node) {
			options[$node->nid] = $node->title;
		}
		$form['field_my_node_reference_nid']['#options'] = $options;
	}
}


Комментарии