Views "plain text" with Link is broken

Created on 23 August 2021, almost 3 years ago
Updated 9 April 2024, 3 months ago

Problem/Motivation

Using Node-Title as View field. Render as "plain text" with option "show Link": Output has no link -> this Module removes the HTML (the surronding <a>)

Proposed resolution

This happens in public function renderText() because $this->options['settings']['link_to_entity'] is 1 (and not TRUE)

just change === to == like here:
if ($this->options['settings']['link_to_entity'] == TRUE && is_array($alter["rendered"]["#title"])) {

🐛 Bug report
Status

Needs work

Version

1.4

Component

Code

Created by

🇩🇪Germany kle

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇩🇪Germany kle

    My proposed solution was wrong... - workaround was adding the link via field-setting to /node/{nid} (something like that).

    Real Solution:

    If I set the field output PLAIN with Option "Link to content" this happens in

      public function renderText($alter) {
        if ($this->options['settings']['link_to_entity'] === TRUE) {
          $alter['rendered']['#title']['#context']['value'] = $this->htmlTitleFilter->decodeToMarkup($alter['rendered']['#title']['#context']['value']);
          $this->last_render = $this->renderer->render($alter['rendered']);
        }
        else {
          $rendered = $this->renderer->render($alter['rendered']);
          $this->last_render = $this->htmlTitleFilter->decodeToMarkup($rendered);
        }
    
        return parent::renderText($alter);
      }
    

    $this->options['settings']['link_to_entity'] has value 1 (not TRUE) so the else-part runs. Thats bad.
    Just change === to ==
    Its even more better to add some more check in line 51 - result is:
    if ($this->options['settings']['link_to_entity'] == TRUE && is_array($alter["rendered"]["#title"])) {

  • Assigned to Indra patil
  • Status changed to Needs work over 1 year ago
  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • Status changed to Needs work 3 months ago
  • 🇺🇦Ukraine quadrexdev Lutsk

    I did not reproduce this issue, "link_to_entity" is always of boolean type, not integer.

    Please see the schema: https://git.drupalcode.org/project/drupal/-/blob/8.8.x/core/config/schem...

    Looks like we need more info to understand/reproduce the problem (if still reproducible)

Production build 0.69.0 2024