2

So I'm not sure where this happening, but would love to understand & fix it.

The same data is being displayed elsewhere on the website without the above issue, only in this exposed filter (& the content editor form) does it seem to happen.

ampersands in views exposed filter

In the configure filter window the ampersands appear as expected:

ampersands in views exposed filter2

The filter is referring to a node reference field:

ampersands in views exposed filter3

If I go to edit one of these content types, the ampersands DO NOT appear correctly either (in select list / drop-down box), only in the configure filter window do they appear correctly.

I checked the database & it's saved in "&" form, so somewhere Drupal is converting it...

I could write a javascript snippet to fix it, but I'd like to understand & fix it the "Drupal way"

3 Answers 3

3

So I used this jQuery search & replace to fix it client side, I still want to find & fix the issue the proper way & will update this when I do. Here is my resulting jQuery snippet:

(function ($) {
$(document).ready(function(){
    $("form#views-exposed-form-maps-page select#edit-destination option").each(function(){
        var text = $(this).text();
        text = text.replace("&", "&");
        $(this).text(text);
    });
});
}(jQuery));
1

It depends on where the exposed filter is coming from. My guess is that on render, the value is escaped twice, one for the label and once for the form itself. Without more info it's not really possible to give a more precise answer.

1

I had the same problem with a h1 title, my solution was to change from:

<?php if ($title): ?><h1 class="title"><?php print $title; ?></h1><?php endif; ?>

to

<?php if ($title): ?><h1 class="title"><?php print str_replace('&amp;', '&', $title); ?></h1><?php endif; ?>

Hope it helps you

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.