This is a hack, but I can't seem to get titles fields only to print in plaintext (so that quotes show up as quotes instead of code). Here are the modules that I applied and tested in hopes that it would fix this problem:
- #1915492: views_json: HTML entities (such as ') still appear even with $plaintext_output chosen This patch successfully made it work when plaintext was enabled. Unfortunately the setting is display-wide, making all fields plaintext.
- #1915446: views_json:Hexadecimal encoding options are not recognized in style settings for use with other bitmask options in json_encode() This patch successfully made it possible to save changes in the selectbox for decoding characters like this. Previously, it wouldn't save those changes. I had hoped this might make something click. This patch fixed this problem but didn't help me.
- #1480884: views field templates not working This patch is supposed to make views_datasources respect field tpl.php files, but it didn't seem to work for me.
Since there's no obvious solution, I hacked this module to decode when the field id is title. Not pretty, I know. But it works, and maybe this is something that can help other people in my position. Obviously I don't expect this to be accepted by the maintainer, but perhaps someone will wander across this issue and figure out a less hacky solution. :-)
views_datasource/views/theme/views_views_json_style.theme.inc: Line 50:
/*
* HACKING THIS MODULE TO MAKE TITLE PLAIN TEXT
*/
if ($field->id == "title"){
$field->content = htmlspecialchars_decode($field->content, ENT_QUOTES);
}
/* END HACKING THIS MODULE */
My hack is relative to json, but I imagine this could apply to others if you hack those files as well.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | decode_entity_labels-2013226-1.patch | 1.52 KB | Anonymous (not verified) |
Comments
Comment #0.0
davidneedhamUpdated issue summary.
Comment #1
Anonymous (not verified) commentedI created a patch to do a similar, but more involved field check in _views_json_render_fields(), which fires before template_preprocess_views_views_json_style_simple() where you made your changes.
Comment #2
kriskhaira commented@rsmylski's patch works for me
Comment #3
rudetrue commentedI think the patches above will still leave '&', '<' and '>' encoded.
Comment #4
yannickooWill work on this tomorrow :)
Comment #6
yannickooCool patch! As you can see following happens:
Current result
"<a href=\"/yannicks-website\">Yannick's <new> & "website" :/</a>"With applied patch
"<a href=\"/yannicks-website\">Yannick's <new> & \"website\" :/</a>"Comment #7
anthonylindsay commentedClosing as no activity for two year, it's in D7 and D6 unsupported.