Problem/Motivation
The 'Page entity label' Views field conveniently checks the type of the entity containing the link and if it's a paragraph, displays the label of the paragraph's parent, and also links to it if there is a canonical link.
Unfortunately this doesn't handle nested paragraphs - e.g. a paragraph within a paragraphs field (e.g. some kind of container/layout paragraph). Patch attached continues getting paragraph parents while they're available, until the root parent is obtained (which will usually be of a type with a canonical link).
The 'Page entity link' Views field is also not functional, but requires similar logic in place to resolve the parent's canonical link.
Steps to reproduce
Attempt to make use of the Page entity label and Page entity link views plugins incorporating nested paragraphs with a module like views_data_export.
Proposed resolution
1. Ensure the Linkchecker has an API for returning the top-most parent entity (so it can be reused in other parts of the code) - see #3611596: [PP-1] Orphaned paragraphs are reported by linkchecker
2. Update the 'Page entity label' and 'Page entity link' Views field so that they use the top-most parent entity for the links.
Remaining tasks
Provide MR and translation tests
User interface changes
N/A
API changes
New LinkCheckerLinkInterface::getTopMostParentEntity() method. (see change record)
Data model changes
The link_to_entity property on the Page entity label field is now a boolean rather than an integer.
| Comment | File | Size | Author |
|---|
Issue fork linkchecker-3135654
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
Comment #2
devkinetic commentedI second this patch, and implemented similar logic over on #3294846: Expose the url to the entity for Views
Comment #3
kle commentedPLEASE PLEASE
add this small change to LinkcheckerLinkPageEntityLabel.php
even in the Drupal-10 Version
########################
Comment #4
vistree commentedI agree. The problem still exists in current version. The patch seems to be clear and small. Why not commit to stable version of the module?
Comment #5
gwvoigt+1 for commiting
Comment #6
eiriksmThis needs to be in a merge request, and it needs tests before being committed
Thanks everyone for working on it and testing ✌️🤓
Comment #7
vistree commentedI recognised today that the language of the parent node is not always the correct one. I have a site with DE + EN - where DE is the default language.
If the parent entity is also a paragraph, I will always get a link to the DE version of the top level node - even the link is on the EN version.
Could we use something like:
Comment #8
vistree commentedPlease ignore my last comment. I figured out that not the translation is the problem - instead orphaned paragraphs are processed by linkchecker. I will try to find a fix for this!
Comment #9
claudiu.cristeaI would use the same code from LinkcheckerLinkPageEntityLink
Comment #10
saidatomComment #11
saidatomComment #13
saidatomCreated the merge request and added test coverage to verify the issue: https://git.drupalcode.org/issue/linkchecker-3135654/-/jobs/11146328
Comment #14
alorencPatch changes a single-level if check into a while loop walking up nested paragraphs via instanceof ParagraphInterface.
Comment #15
alorencComment #16
alorencComment #18
codebymikey commentedIncreased the scope of the ticket to also address the non-functional Page entity link views fields since it requires similar logic. Also updated the tests to include basic translation support as per #3506219: Create tests for showing the translated entity link.
The test-only changes should also be failing.
NB: you need to add schema.yml to test-only extra pattern, otherwise it will fail at the config schema level