Problem/Motivation

The link field is not visible in the summary.
If you have a paragraph type "link" that only has a link, it has an empty summary.
That makes understanding the context hard.

Proposed resolution

Support link fields like any other.
Let's display the URL, not the label.

Remaining tasks

User interface changes

API changes

Data model changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

miro_dietiker created an issue. See original summary.

miro_dietiker’s picture

Affects Paragraphs Collection where we have a Link field.

Maybe output the link URL if there is no label - like the label behaves when rendering.

johnchque’s picture

Assigned: Unassigned » johnchque

Working on this. :)

johnchque’s picture

Status: Active » Needs review
FileSize
2.74 KB

This should work. :)

Berdir’s picture

Status: Needs review » Needs work
+++ b/src/Entity/Paragraph.php
@@ -475,6 +475,18 @@ class Paragraph extends ContentEntityBase implements ParagraphInterface {
+          // If no title is set, fallback to the uri.
+          if ($title = $this->get($field_name)->first()->getProperties()['title']->getValue()) {
+            $summary[] = $title;
+          }
+          else {
+            $summary[] = $this->get($field_name)->first()->get('uri')->getValue();
+          }

that's certainly an impressively complex way to get at the properties. You just need $this->get($field_name)->/title/uri, gives you the same.

toncic’s picture

+++ b/src/Entity/Paragraph.php
@@ -475,6 +475,18 @@ class Paragraph extends ContentEntityBase implements ParagraphInterface {
+          // If no title is set, fallback to the uri.

Optional, this sound a bit strange maybe just reorder words to be 'If title is not set ...'

johnchque’s picture

Status: Needs work » Needs review
FileSize
2.67 KB
763 bytes

Right, changed and updated.

miro_dietiker’s picture

Status: Needs review » Fixed

Awesome, committed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.