8000 Make it easier to add documents to pages · Issue #253 · localgovdrupal/localgov_core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Make it easier to add documents to pages #253

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
willguv opened this issue May 8, 2024 · 17 comments · Fixed by #254
Closed

Make it easier to add documents to pages #253

willguv opened this issue May 8, 2024 · 17 comments · Fixed by #254
Assignees

Comments

@willguv
Copy link
Member
willguv commented May 8, 2024

Mentioned at LGD Camp, and also picked up by @benhillsjones in Dumfries

As a content designer
I need to insert a document at a specific point on a page and give it custom link text

@dedavidson has been working on a fix for this

@willguv willguv changed the title Make it easier to add images and documents Make it easier to add documents May 8, 2024
@willguv willguv changed the title Make it easier to add documents Make it easier to add documents to pages May 8, 2024
@dedavidson
Copy link

The fix for this is to add config to modules/localgov_media/config/optional/linkit.linkit_profile.default.yml the localgov_core project. ( https://github.com/localgovdrupal/localgov_core/blob/2.x/modules/localgov_media/config/optional/linkit.linkit_profile.default.yml )

It requires adding the following config to the matchers section:

  <a uuid>:
    id: 'entity:media'
    uuid: <a uuid>
    settings:
      metadata: ''
      bundles:
        document: document
      group_by_bundle: false
      substitution_type: media
      limit: 100
    weight: 0

@SarahQ83
Copy link

How would this fix then work for an editor?

@markconroy
Copy link
Member

Hi @SarahQ83

If you are familiar with how the LinkIt module works, we would just be extending that to allow linking to documents as well as other pages on the website. At the moment, LinkIt only searches for other pages on the site.

If you are not familiar with LinkIt, it's a module that helps with creating links in a wysiwyg editor. It allows us to search for a piece of content to link to, and then insert that link in the wysiwyg. Crucially, if the URL for the link ever changes, you do not need to go back to where you added the link in the wysiwyg as LinkIt will automatically update all references to the link.

===
Thanks to Big Blue Door for sponsoring my time to work on this.

@SarahQ83
Copy link
SarahQ83 commented Jun 5, 2024

Hi @markconroy that sounds simple enough, thanks

@RyanFH257
Copy link

To maintain consistency with adding documents via the Media button and to reduce the manual effort, it would be good if when you added a document via Linkit, the file type and size is included at the end of the link.

@markconroy markconroy transferred this issue from localgovdrupal/localgov Oct 1, 2024
@markconroy
Copy link
Member

I have a PR for this.

@RyanFH257 this won't add the file size, etc in the URL. LinkIt is just for creating basic links. If you want that extra metadata you will need to embed the document via the media widget as normal.

@SarahQ83 if you want to add this to your existing site, go to /admin/config/content/linkit/manage/default/matchers and click "Add matcher". Then put these settings into the form:

Screenshot 2024-10-01 at 11 26 21


Thanks to Big Blue Door for sponsoring my time to work on this.

@finnlewis
Copy link
Member

Another way might be the embedded media entity.

This will allow the content designer to browse for a document and embed it, displaying the file size / type etc.. This would not allow customised link text.

@Adnan-cds has some solution that is similar to the requirements.

@markconroy
Copy link
Member
markconroy commented Oct 15, 2024

From Slack:

ekes (agile/iskra)
Sep 5th at 11:37 AM
I'm doing a review/summary of the download file link options
(specifically the issue about updating files - so serving the current up to date version not previous version, while avoiding any upstream cache issues)
Usual suspects on my list:
https://www.drupal.org/project/media_entity_download
https://www.drupal.org/project/media_entity_file_redirect
https://www.drupal.org/project/media_entity_file_replace
https://www.drupal.org/project/file_replace
I know this is a common issue, and maybe one we could suggest best practice for LGD? I know we have these download links on service pages, which I find unusual, but guess might have been for the same reason?
Has anyone else already made notes / issue / docs. I've seen it discussed here before, but don't find it anyway.
Drupal.org
Media Entity Download
Media entity download solves a content management issue when dealing with files and media. Media entity download will prevent links from breaking when updating or uploading new files.
Sep 19th, 2017
Drupal.org
Media Entity File Redirect
Overview This simple modules provides a new path /document/[id] which redirects to the file source of a media entity.
Dec 4th, 2018
Drupal.org
Media Entity File Replace
This module allows content editors to easily replace the source files associated with file-based media types (like "Document").
Jan 1st, 2020
Drupal.org
File Replace (D8+)
The file replace module is a small utility providing site administrators with the possibility to replace files, keeping the file uri intact.
Jan 21st, 2019
7 replies

8000 Mark Conroy (the-confident.com)
Sep 5th at 11:43 AM
I’m only aware of any councils using Media Entity Download, and none of the other modules.

Rupert Jabelman (Chicken)
Sep 5th at 11:47 AM
Same.

Alistair Wearring (West Lindsey / North Kesteven)
Sep 9th at 11:45 AM
Big Blue Door set up Media Entity File Replace for us -so might be worth asking
@Louwrens Erasmus (Big Blue Door)
or
@Simon Stewart (Big Blue Door)
about that module
👍
1

Louwrens Erasmus (Big Blue Door)
Sep 9th at 12:09 PM
We've used https://www.drupal.org/project/media_entity_file_replace on both LGD and non-LGD projects. It seems to work pretty well, allowing CMS admin users to replace a file with a newer version while retaining the same URL, media entity, etc. even if the new file has a different file name.
🙌
1

ekes (agile/iskra)
Sep 9th at 12:12 PM
You've not encountered any of the mentioned issues with upstream caches, or are your webservers all well configured to include headers to make sure the file is checked or so?
I think the second issue of multiple files on a media entity is pretty marginal.

Louwrens Erasmus (Big Blue Door)
Sep 9th at 12:27 PM
We do sometimes need to clear CDN caches manually after a file has been replaced, but I think that is expected. That module seems to work pretty well from a Drupal caching point of view and our sites are normally set up well to include headers, etc. as you mentioned.
@alistair Wearring (West Lindsey / North Kesteven)
Have you seen any caching issues when replacing files on WL or NK? (edited)

Alistair Wearring (West Lindsey / North Kesteven)
Sep 9th at 12:36 PM
As far as I am aware we've not seen any issues within Drupal itself, as
@Louwrens Erasmus (Big Blue Door)
mentioned we do need to clear the CDN cache

@finnlewis
Copy link
Member
finnlewis commented Oct 15, 2024

@ekes has another clever (crazy?) approach which he might be able to share?

(Something that involves a new database table which is used as a lookup before the full Drupal bootstrap)

@willguv
Copy link
Member Author
willguv commented Dec 18, 2024

@willguv to review how does GDS does this eg https://www.gov.uk/government/publications/the-state-of-health-care-and-adult-social-care-in-england-in-2012-to-2013

Local gov doesn't generally do this. We need to discuss with the content group what's typical now and the best way forward

Ryan: raised linking to external docs

Paul B: forces format and size to appear in link text (check for examples). When doc is uploaded, provide an easy read name and number of pages

Here's the nicer styling https://haringey.gov.uk/about-this-website/website-improvements/past-future-user-research and some of the inline styling examples are here https://haringey.gov.uk/children-young-people-families/send-local-offer/send-improvement/send-executive-board

James: Some guidance on this page, encouraging not linking directly to docs where possible: Content design: planning, writing and managing content - Links - Guidance - GOV.UK

Maria: Local Welfare Scheme | Bracknell Forest Council

@willguv willguv self-assigned this Jan 30, 2025
@willguv
Copy link
Member Author
willguv commented Jan 30, 2025

From @benhillsjones

As a content designer
I need to insert a document at a specific point on a page and give it custom link text

Two current issues:

  • no “display title” field in the media item, so inserted doc takes the file name

  • when highlighting text to make a link, the doc doesn’t appear in a list of items to link to

@willguv willguv moved this from In Progress - Core team to 2025 'Refresh' mission [REFINE AND PRIORITISE] in 2025 Refresh/ Editor experience Feb 13, 2025
@willguv
Copy link
Member Author
willguv commented Mar 27, 2025

@finnlewis @ekes thinking aloud here

Going back to the original need from @benhillsjones:

As a content designer
I need to insert a document at a specific point on a page and give it custom link text

@markconroy's proposed change around extending the LinkIt module seems to cover this

Steps for an editor:

  • types in text and highlights the part they wish to create a link from
  • clicks the link icon
  • searches for the doc name and selects it
  • if the doc is external, the editor adds a url and then selects it
  • a link is created to the doc

We can then choose whether to append file size/ type etc

While linking directly to a doc isn't good GOV.UK practice, it's common in local gov and think we need to support it

This route would also allow an editor to select a publication, which is what GOV.UK recommends

What's being linked to?

Finn asked

What is the expected behaviour of a LinkIt link to a document? Is it:
a) to the canonical url of the media item (/media/123)
b) to the file that is the target of the media item? (/sites/default/files/my-file.pdf)
c) to a download link (/media/123/download)

I think if users and editors are expecting anything, it's probably b). Rolling over the link shows the thing that's going to be downloaded. I've not asked content group recently, but can go back to them

Versioned docs

I've not considered councils wishing to replace a doc with a new version. Would https://www.drupal.org/project/media_entity_file_replace mentioned above do that?

@ekes
Copy link
Member
ekes commented Mar 27, 2025

Would https://www.drupal.org/project/media_entity_file_replace mentioned above do that?

From my notes above. Yes. Unless you use an upstream cache - which is almost everyone. Then it needs flushing if you make a change it seems.

@willguv willguv moved this from 2025 'Refresh' mission [REFINE AND PRIORITISE] to In Progress - Core team in 2025 Refresh/ Editor experience Apr 3, 2025
@willguv willguv moved this to Ready in 2025 Priorities Apr 3, 2025
@willguv willguv removed the status in 2025 Priorities Apr 10, 2025
@finnlewis
Copy link
Member

Discussing with @danchamp , received wisdom on presentation is:

The link to the file should:

  • describe the information contained within the file.
  • the file type
  • the file size

Actual file name?

  • don't expose them. Listening to a file name in screen reader is often horrendous!

Other thougts:

  • Having a download link that obfuscates the file name helps with cache issues.

@willguv
Copy link
Member Author
willguv commented Apr 17, 2025

Does option c) set us up better for future work on caching @finnlewis?

Also @ekes mentioned standard Drupal behaviour - which option is this please?

Thanks both for quick replies

@willguv
Copy link
Member Author
willguv commented Apr 22, 2025

Let's discuss this in #254

Closing issue

@willguv willguv closed this as completed Apr 22, 2025
@github-project-automation github-project-automation bot moved this from In Progress - Core team to Done in 2025 Refresh/ Editor experience Apr 22, 2025
@finnlewis finnlewis reopened this May 8, 2025
@finnlewis
Copy link
Member

Opening this again, we've not resolved this just yet!

@willguv willguv moved this from Done to In Progress - Core team in 2025 Priorities May 8, 2025
@willguv willguv moved this from Done to In Progress - Core team in 2025 Refresh/ Editor experience May 8, 2025
@github-project-automation github-project-automation bot moved this from In Progress - Core team to Done in 2025 Refresh/ Editor experience May 8, 2025
@github-project-automation github-project-automation bot moved this from In Progress - Core team to Done in 2025 Priorities May 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

7 participants
0