I want to combine the [type] and [entity_id] (body field) as well as control the output of it.

For the [type] I have excluded it and rewritten the output to:
<strong><em>[type] - </em></strong>

For the [entity_id] I have rewritten the output to:
[type][entity_id]

I have also set it to strip the HTML tags.

The problem is that is also strips the HTML tags for the [type].

This sort of limits the way I can format the output. It would be great if the Strip HTML tags option only strips the tags for the field it is set for, not any fields in the rewrite textarea.

Alternatively have two options:

- Strip HTML tags for this field only
- Strip all HTML tags

Comments

tsvenson’s picture

I did some more testing with this and checking the strip HTML tags option renders the rewrite useless. It seems to me that the strip HTML tags is applied after all the other rendering is done and then.

Personally I would like it to default to strip HTML tags for the field content it is set for before any rewrites or other formattings are made.

dawehner’s picture

Version: 7.x-3.x-dev » 6.x-3.x-dev

I don't think we can trust the user here, moving the DRUPAL-6--3 because this is the current version were features will be handled

merlinofchaos’s picture

Status: Active » Closed (won't fix)

The workaround is to use global: custom field. The normal field has strip applied, adn then its token is used in the custom field with your HTML. Maybe not elegant but it's safer and easier.

alanom’s picture

This isn't a complete workaround, since the rewritten markup in your Global: Customfield will be displayed even if the field it wraps around is empty.

If this is a problem, here is an (even uglier) workaround that still maintains the feature of not trusting the user (not 100% sure why this is a feature since surely if they were malicious and ha access to Views UI they could just untick the 'Strip HTML' box, but that's a seperate debate) but which only shows the rewritten markup if the field is non-empty.

Example use case: You're trying to wrap a custom link around a Media-module File field showing a Youtube thumbnail from earlier stable versions where the only formatters loaded into Views linked thumbnails to the Media entity (call it Field: Video). You want to remove the <a> tags the formatter wraps around an <img>, then wrap your own <a> tag around it - only if the field is actually present in this row. (maybe there's another way to do this in Media, if so, imagine there wasn't and just treat this as an illustrative example)

  • Have two occurences of the same field - two Field: Videos
  • In the first Field: Video, exclude from view, and set Strip Tags to strip everything non-essential (in this case, we'll keep the <img> but nothing else)
  • In the second Field: Video, set the formatter to whatever requires least processing, because we won't be using it (in this case, probably File URL, or the same as before if it caches), and then write in our markup, wrapping around the replacement token of the first Field: Video field

So the second field, only if not empty, shows the first (stripped) field wrapped in its own (non-stripped) markup.