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.

Comments

RKopacz created an issue. See original summary.

valderama’s picture

StatusFileSize
new42.95 KB

In 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

RKopacz’s picture

Thanks @valdemara , great idea! I'll give that a try. Sorry for the late reaction!

colan’s picture

Version: 8.2.1 » 8.9.x-dev
Category: Support request » Bug report

I'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...

colan’s picture

I gave up on this as I found a workaround:

  1. Add the Content: ID field before the edit field, and exclude it from display.
  2. Rewrite the results as <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.

colan’s picture

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

pameeela’s picture

Status: Active » Postponed (maintainer needs more info)
Issue tags: +Bug Smash Initiative, +Needs steps to reproduce

I'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:

<td headers="view-title-table-column--n_pwIg-AmyE" class="views-field views-field-title views-field-body">
<a href="/node/470" hreflang="en" data-once="views-ajax">Test with comments</a>
<p>Body text here with <strong>some HTML</strong>.</p>
<a href="/node/470/edit?destination=/admin/structure/views/view/duplicate_of_manage_corporate_active_requests/preview/page_1%3F_wrapper_format%3Ddrupal_ajax" hreflang="en" data-once="views-ajax">edit</a>
</td>

Fields displayed in separate columns:

<td headers="view-title-table-column--N3fpHc6FMWU" class="views-field views-field-title">
<a href="/node/470" hreflang="en" data-once="views-ajax">Test with comments</a>
 </td>
<td headers="view-body-table-column--Dxql8bimhMU" class="views-field views-field-body">
<p>Body text here with <strong>some HTML</strong>.</p>
</td>
<td headers="view-edit-node-table-column--8z0MW96QIvM" class="views-field views-field-edit-node">
<a href="/node/469/edit?destination=/admin/structure/views/view/duplicate_of_manage_corporate_active_requests/preview/page_1%3F_wrapper_format%3Ddrupal_ajax" hreflang="en" data-once="views-ajax">edit</a>
</td>

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.

luke.stewart’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

Nine months has lapsed.

No update since then.

Closing.

erwangel’s picture

Set 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".