My title field is rewritten to include other fields and html span and div tags, but this module strips the html from the output which makes this module useless in my case. Otherwise this would be a great module.

Comments

iamfredrik created an issue. See original summary.

trudog’s picture

in templates/accordion/theme.inc you have a hook for template.php. you can adjust the title if you like...

AliMartin’s picture

Hi Pisicosu - could you prefer further instructions on the required changes in theme.inc please? My attempts so far continually break the code and functionality. It be great some basic markup to allow greater styling, or provide additional unique classes on each of the panels to allow CSS targeting. Many thanks in advance :) Ali

trudog’s picture

1. DON'T modify theme.inc!
2. In /sites/all/modules/views_bootstrap/templates/accordion/theme.inc, there's a function called template_preprocess_views_bootstrap_accordion_plugin_style. Copy the whole function.
3. Paste the copied function to your theme folder in template.php.
4. Replace "template" word in function name with your theme name.
5. Inside this function, change the following line:

$vars['titles'][$key] = strip_tags($view->style_plugin->get_field($key, $title_field));

to

$vars['titles'][$key] = $view->style_plugin->get_field($key, $title_field);

6. At this point, the title is no longer filtered.
7. IMPORTANT: I haven't studied the security implications since it is not necessary in my case.

8. Here's my code as a reference.

/**
 * Implementation of template preprocess for the view.
 */
function mytheme_preprocess_views_bootstrap_accordion_plugin_style(&$vars) {
  $view = &$vars['view'];
  $title_field = $vars['options']['title_field'];

  $vars['classes_array'][] = 'panel-group';

  // Get titles.
  if (isset($view->field[$title_field])) {
    foreach ($vars['view']->result as $key => $field) {
      $vars['titles'][$key] = $view->style_plugin->get_field($key, $title_field);
    }
  }
}
lazyD’s picture

Thanks trudog,

This code worked for me.

Can we have a feature in views bootstrap module a checkbox which allow html in accordion panel-title?

lazyD’s picture

Assigned: Unassigned » lazyD
Status: Active » Needs review
StatusFileSize
new762 bytes
new790 bytes

Attached a patch files, if someone can test and close this issue.

lazyD’s picture

Missed a declaration in views bootstrap accordion plugins style file.

Please refer updated patch file.

kbrinner’s picture

As an alternative we could just switch from using the strip_tags() function to using filter_xss_admin() which I believe is standard for views in terms of sanitizing input. So, in the template override it would be:

/**
 * Override Views Bootstrap stripping of html from tab title
 */
function [MYTHEMENAME]_preprocess_views_bootstrap_tab_plugin_style(&$vars) {
  $view = &$vars['view'];
  $tab_field = $vars['options']['tab_field'];

  $vars['tab_type'] = $vars['options']['tab_type'];
  $vars['justified'] = $vars['options']['justified'];

  // Get tabs.
  if (isset($view->field[$tab_field])) {
    foreach ($vars['view']->result as $key => $field) {
      $vars['tabs'][$key] = filter_xss_admin($view->style_plugin->get_field($key, $tab_field));
    }
  }
}

I'm going to submit this as a patch to Views Bootstrap as well, as I think this would be an improvement. We'll see if they think it's secure enough.

chris matthews’s picture

Version: 7.x-3.1 » 7.x-3.x-dev
Assigned: lazyD » Unassigned
Status: Needs review » Needs work
Issue tags: +Needs reroll

The 2 year old patch in #7 does not apply to the latest views_bootstrap 7.x-3.x-dev and needs a reroll.

shelane’s picture

Status: Needs work » Closed (cannot reproduce)

Actually, it is using the field based on the field setting. If you are using a field that is a plain text field, the html will be encoded. If it's a full text field, it will output the html as is and as filtered by the field type if you use the default field formatter.