I just noticed that when I select a table format, and seek to group one or more fields into a single column, that the content from the field being grouped is stripped of all HTML. It would be nice to at least get a span wrapped around that content, because right now, there are just three text strings running together, without even a space between them.
Does anyone know if there is a way around this default behavior in the Views UI? I have looked all through the table settings and the field settings and can't see anything that would permit me to get something wrapped around the content for the fields being so grouped. Ideally, I would like at least a span or div wrapped around those items being grouped, so that the won't run together.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | Bildschirmfoto 2017-03-09 um 11.31.30.JPG | 42.95 KB | valderama |
Comments
Comment #2
valderama commentedIn D7 you can work around this by putting both field in the same column by using an alternative way. You can hide one field and output it in the content of the other field by using the "Rewrite output" feature with replacement patterns.
See the attached screenshot.
Best,
Walter
Comment #3
RKopacz commentedThanks @valdemara , great idea! I'll give that a try. Sorry for the late reaction!
Comment #4
colanI'm currently running into this with the Link to edit Content field, which provides the
{{ edit_node }}token. It's rendering edit as pure text, no link, as soon as I use it as described in this ticket. Other tokens from earlier fields are being rendered fine with HTML, however. It seems like it only works if it's the first HTML-containing token. When I place it after any other ones, I get pure text. Digging...Comment #5
colanI gave up on this as I found a workaround:
<a href="node/{{ nid }}/edit">edit</a>.So I'm overriding what
{{ edit_node }}is supposed to be doing. Any tips on how to avoid this hack (and fix Views) would be appreciated. I tried stepping through the code with a debugger, but with the time I spent, I couldn't figure out where the token is supposed to be replaced.It gets set in FieldPluginBase:
$tokens[$placeholder] = $handler->last_render;...but that handler, EntityLinkEdit, doesn't appear to have a class variable
$last_render(or inherit it from anywhere else) so I have no idea where it's coming from. Grepping through all of core didn't seem to help either.So the trick in #2 works in D8 as well.
Comment #6
colanComment #14
pameeela commentedI'm not sure whether something has changed, but I can't reproduce the HTML stripping here. If I have a field with HTML, it displays the same way whether it its own column or grouped.
Fields displayed in the same column:
Fields displayed in separate columns:
If the OP or anyone else has info on how to reproduce, please update the issue summary with specific steps. If that is not provided, this issue may be closed after 3 months.
Comment #15
luke.stewart commentedNine months has lapsed.
No update since then.
Closing.
Comment #16
erwangel commentedSet following fields:
- "Content: Image"
- "Content: Authored by" [hidden] and in "Style settings" Customize field HTML "EM"
- "Content: Authored on" with "Rewrite results"
{{ uid }} - {{ created }}Already here "Authored on" lost its EM while "Strip HTML tags" is "off"- "Content: Title" and in "Style settings" Customize field HTML "H3"
All fields have "Add default classes" in "Style settings"
Format as table with:
Content: Image in column Content: Image
Content: Authored on in column Content: Title
Content: Title in column Content: Title
Results to a
<td>where: "Authored by" loses its "EM" tag and the rewritten "Authored on" is wrapped in the Title's H3!<h3>Author's name - Date <a href="article link">Title</h3>Even if we wrap "Authored on" in a div it remains inside the title's H3
- Content: Authored on with "Rewrite results"
<div><em>{{ uid }}</em> - {{ created }}</div>Result:
<h3><div><em>{{ uid }}</em> - {{ created }}</div> <a href="article link">Title</h3>The only way to overcome is to manually group and format everything in title's "Rewrite results"
<div><em>{{ uid }}</em> - {{ created }}</div><h3>Title<h3>So I see two problems: one with rewriting, where customized html tag is lost, and the second with table format where grouping fields in a column strips previous html and wraps fields in the last field's tagging.
Anyway one would expect that each field preserves its own html tagging ans style settings unless it is specified to "Strip HTML tags".