Skip to content
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

Make it easier to add documents to pages #253

Open
willguv opened this issue May 8, 2024 · 10 comments · May be fixed by #254
Open

Make it easier to add documents to pages #253

willguv opened this issue May 8, 2024 · 10 comments · May be 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 markconroy linked a pull request Oct 1, 2024 that will close this issue
@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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress - Core team
Development

Successfully merging a pull request may close this issue.

7 participants