'
' . t('Add custom template suggestion for your view templates.') . '
', ); $template_suggestion = $this->get_template_suggestion(); $form['template_suggestion'] = array( '#type' => 'textfield', '#title' => 'Custom template suggestion (machine-name style)', '#default_value' => $template_suggestion, '#size' => 30, '#maxlength' => 30, '#description' => t( '

"My Custom Template" will become "my_custom_template (machine-name)".
All levels Views templates will use this suggestion: view, row, field.

Example: My Custom Template

The template suggestion will be used after you flush the theme registry cache.

'), ); } } /** * Save option to display */ function options_submit(&$form, &$form_state) { parent::options_submit($form, $form_state); $template_suggestion = $this->get_template_suggestion($form_state['values']['template_suggestion']); $this->display->set_option('template_suggestion', $template_suggestion); } /** * Provide the default summary for options in the views UI. * * This output is returned as an array. */ function options_summary(&$categories, &$options) { // Never for the Master display. if (!empty($this->display->default_display) && $this->display->default_display != $this->display) { parent::options_summary($categories, $options); $template_suggestion = $this->get_template_suggestion() ?: t('None'); $options['template_suggestion'] = array( 'category' => 'other', 'title' => t('Template suggestion'), 'value' => $template_suggestion, 'desc' => t('Change the template suggestion that will be added to this display.'), ); } } function get_template_suggestion($template_suggestion = '') { if (!$template_suggestion) { $template_suggestion = $this->display->get_option('template_suggestion'); } $template_suggestion = _format_views_custom_template_suggestion($template_suggestion); return $template_suggestion; } }