List of printer-friendly urls has links not printed in output.

Created on 12 February 2024, 10 months ago
Updated 1 March 2024, 9 months ago

Problem/Motivation

While looking for ways to reproduce πŸ› Duplicate Links with subscript reference doesn't match up with Printer-friendly URLs list at bottom of page. Active I noticed that for every entity that I displayed I got an additional link to the printable version in the list of printer-friendly links at the end of the page.

I always get an additional link to a printable/print page for every entity that I display that is using the printable view mode.

That said, the links to the embedded entities may actually be the canonical link when displayed... and the extracted link handling shows this.

https://www.drupal.org/files/issues/2024-02-12/KNoXi_E2G7.png β†’
https://www.drupal.org/files/issues/2024-02-12/Screenshot%20from%202024-... β†’

In the first one, Note that at the bottom there is a bunch of nodes embedded as an entity embed reference field under the "Forms Required" header. The link in each of these in the extended format shows the link it's supposed to go to, but links 38-50 are "printable" link versions of each of those. If I change the display view mode to "default" for example, I only get the original link.

In the second one, you notice I'm getting the link for the page I'm visiting. This infact happens on my first example too, which is Link 51.

Steps to reproduce

create a new install of Drupal with Printable 3.x-dev installed.
Navigate to /admin/config/user-interface/printable
Choose Link handling: Extract
Click Save
Click the Print tab (/admin/config/user-interface/printable/print)
Choose "Printer-friendly URLs list in system Pages"
Click Submit
Navigate to /node/add/article
Add the following content to the body <p><a href="https://google.com">https://google.com</a></p><p><a href="https://yahoo.com">https://yahoo.com</a></p><p><a href="https://google.com">https://google.com</a></p>
Click Save
Navigate to /node/1/printable/print
Note that Link 5 isn't displayed anywhere in the "Extracted"/Expanded format of all the links above.

Proposed resolution

My expectation was that the list of links that show up when you use the "Extract" Link handling and "printer-friendly URLs list" would match one for one, at the worse just reduce duplicates... but this wasn't the case.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States generalredneck

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

Comments & Activities

  • Issue created by @generalredneck
  • πŸ‡ΊπŸ‡ΈUnited States generalredneck
  • πŸ‡ΊπŸ‡ΈUnited States generalredneck

    Well tracked down the Printable links for embedded content. There's css in printable.html.twig that hides the links.

        .node_view ul li{
        display:none;
        }
    

    ugh...

    So the options as they stand for me now are:
    1) Configure embeded entity view mode such that it doesn't show the "links" section (which would suck if there was links in the link section I needed, but works for me here).
    2) use a preprocesssor function that strips the Printable Link out of the Links area for those very specific content types and view modes.

    This is going to affect πŸ› Duplicate Links with subscript reference doesn't match up with Printer-friendly URLs list at bottom of page. Active because if we put a subscript next to all links, some of the subscripts are going to appear to be missing.

  • πŸ‡ΊπŸ‡ΈUnited States generalredneck

    Ok so Option 1 is out above. Looks like the only way a printable link isn't printed on an entity is if that entity's template explicitly removes the links variable from being rendered.

    I may need to refactor this issue to be "Printable doesn't respect the "links" field in the Manage Display section on Node entities...

    Custom template or preprocessor it is!

  • πŸ‡ΊπŸ‡ΈUnited States generalredneck

    Anyone else looking to do what I'm doing, if you have theme hook suggestions for display modes... try something like node-printable.html.twig and put something like:

      <div{{ content_attributes }}>
        {{ content|without('printable_navigation') }}
      </div>
    

    In it. This removes the links that are currently hidden via css.

    I think an appropriate patch may be to add an if statement in printable_entity_view that checks for $view_mode == 'printable', and just exclude printable_navigation entirely. I don't see that we need those links in the printer friendly version, and if we do, it should likely replace the links to existing entity as opposed to creating a hidden link.

  • Status changed to Fixed 10 months ago
  • πŸ‡¦πŸ‡ΊAustralia nigelcunningham Geelong

    Thanks for this report.

    I've just pushed a series of commits that fix this issue. As part of the fix, they add a new option to the link extractor config form that lets you choose whether to exclude the Printable links from the list. It defaults to enabled for backwards compatibility.

  • πŸ‡¦πŸ‡ΊAustralia nigelcunningham Geelong
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024