When displaying nodes using Views and it's translation features, and using Display Suite as the row plugin, the configured alternating view modes and other configurations (like advanced view mode hook) are not taken into account.

It seems that the "preRenderByRelationship" method is not implemented at all, resulting in the default behavior being used.

Here is a patch that fix this issue, but maybe not the most efficient way.

Issue fork ds-3025928

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Renrhaf created an issue. See original summary.

renrhaf’s picture

renrhaf’s picture

Patch explained

Remove the default views preRender behavior as it implies rendering useless markup because it gets overriden by DS configurations later.

public function preRender(array $result) {
-    parent::preRender($result);
     $this->dsPreRender($result);
   }

Adds the override of the preRenderByRelationship method, if not, only the views default behavior is used which implies using the default view mode configured on the view, and not considering DS ones.

+  /**
+   * {@inheritdoc}
+   */
+  public function preRenderByRelationship(array $result, $relationship) {
+    $this->dsPreRenderByRelationship($result, $relationship);
+  }
+

Move the code logic from the previous dsPreRender method to this new one.

+  /**
+   * Pre renders all the Display Suite rows.
+   *
+   * @param \Drupal\views\ResultRow[] $result
+   *   The full array of results from the query.
+   * @param string $relationship
+   *   The relationship to be used.
+   * @param bool $translation
+   *   Should the rendered be stored under translation key.
+   */
+  protected function dsPreRenderByRelationship(array $result, $relationship, $translation = FALSE) {
     if ($result) {
     ...
renrhaf’s picture

Status: Active » Needs review

Status: Needs review » Needs work
renrhaf’s picture

StatusFileSize
new12.78 KB

Rerolled against 8.x-3.x

swentel’s picture

Status: Needs work » Needs review
swentel’s picture

Status: Needs review » Needs work
cbccharlie’s picture

I attached a new patch for 8.3.4 module version.

Please, could you test it?

swentel’s picture

Altered heavily by #3191628: Bring back 'delta' rendering, but will look at it soon.

swentel’s picture

Pinging myself again, need to get this in soon

swentel’s picture

Status: Needs work » Closed (outdated)

As far as I can see, this seems to be working for me, unless I've done something wrong in my setup - maybe after #3191628: Bring back 'delta' rendering?
But I could be wrong, so if this is still a problem, please reopen!

javier_rey’s picture

This issue is related to "Cannot use relationship for rendered entity on Views". Applying the core patch, the display suite module breaks and ignores the "Alternating View Mode" option

javier_rey’s picture

Related to my previous comment, I have uploaded a patch that fixes the display suite "alter view mode" option when applying the core patch.

swentel’s picture

Status: Closed (outdated) » Active

Ah ok, I'll reopen the issue to keep tracking this.

swentel’s picture

Version: 8.x-3.x-dev » 5.0.x-dev
swentel’s picture

Priority: Major » Normal
Status: Active » Postponed

Postponed until the core patch goes in.

swentel’s picture

Status: Postponed » Active

Core patch is in, but only in 10.1.x (for now)

cbccharlie’s picture

I attached a new patch for 8.x-3.15 module version.

klaasvw’s picture

This patch is compatible with drupal core 9.5.x using the patch from https://www.drupal.org/project/drupal/issues/2457999#comment-14853680

klaasvw’s picture

Forgot fixing the TranslationLanguageRenderer; new patched attached.

YevKo made their first commit to this issue’s fork.

swentel’s picture

Version: 5.0.x-dev » 8.x-3.x-dev

moving back to 8.x-3.x

swentel’s picture

Priority: Normal » Major
swentel’s picture

Status: Active » Needs review
StatusFileSize
new6.68 KB

re-roll against 8.x-3.x

  • swentel committed 13f4a596 on 8.x-3.x
    Issue #3025928 by Renrhaf, cbccharlie, klaasvw, swentel, Javier_Rey:...
swentel’s picture

Status: Needs review » Fixed

committed and pushed, thanks!
(note my version is smaller because I've added a 'continue' in dsPreRender when checking if the entity exists or not.

swentel’s picture

Status: Fixed » Closed (fixed)