0

im having a little trouble theming the output of a view's exposed filter.

I have a node reference field, and in the exposed filter i want to show it as a checkbox list with, instead of the title of the referenced node, the image (that is a field, obvious).

Im doing the same thing for the node_edit form:

    // This function is called via #process fapi key
function _mytheme_theme_pittogrammi(&$element)
{
    $lang = isset($element['it']) ? 'it' : 'und';

    foreach($element[$lang]['#options'] AS $nid => $label)
    {
        $pittogramma = node_load($nid);
        $image_field = _dwork_field_get_value($pittogramma->field_image);

        $image = '<img class="bubbleUp" src="'
                . image_style_url('pittogrammi', $image_field[0]['uri']) . '" alt="'
                . $pittogramma->title .'" title="' . $pittogramma->title .'" />';

        $element[$lang]['#options'][$nid] = $image;


        $element[$lang][$nid] = array(
            '#label' => $image
        );
    }
    return $element;
}

and it works perfeclty; For the view_exposed_form i hat to make a little change in the function (becose the lang is not present), but is almost the same:

function _mymodule_theme_pittogrammi_view_form(&$element)
{
    foreach($element['#options'] AS $nid => $label)
    {
        $pittogramma = node_load($nid);
        $image_field = _dwork_field_get_value($pittogramma->field_image);

        $image = '<img class="bubbleUp" src="'
                . image_style_url('pittogrammi', $image_field[0]['uri']) . '" alt="'
                . $pittogramma->title .'" title="' . $pittogramma->title .'" />';

        $element['#options'][$nid] = $image;


        $element[$nid] = array(
            '#label' => $image
        );
    }
    return $element;
}

And this works somehow, but the problem is that the image HTML looks like is passed throught htmlspecialchars() or something like, and rendered as text.

Im wondering why and why only on view's exposed form...

How can i change this behavior?

1
  • typically #label and #title values for FAPI elements are passed through drupals xss_filter() function. I assume Views is being more strict -- because it's so widely used.
    – tenken
    Sep 26, 2012 at 3:58

1 Answer 1

0

Solved: I am using BEF module (Better Exposed Filters) that, in row 532 of better_exposed_filters.theme used to check_plain even the label.

Commenting that line do the trick, knowing that youre raping someone'else module (but this is the only way i found since there is no an option to dont check_plain the label)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.