Generic links to resources in resource file to stay in tact during restore

Generic links to resources in resource file to stay in tact during restore

by Louisa van der Linden -
Number of replies: 6

We have a 2018 course site with a PDF document that contains links to other files and videos on the same course site.

The effect: Student download the PDF and click on interactive links which direct them to specific resources on the rest of the site.

We want to create this same course site in 2019 without re-linking the PDF document since there's several hundred links across multiple courses.

I tried to Import the 2018 site into the 2019 site and also tried the backup-restore method. In  both cases the links direct back to the 2018 site. 

How can we insert generic enough links in our PDF files so that it can link to a specific topic > file regardless of course site. So a relative path instead of an absolute one.


Average of ratings: -
In reply to Louisa van der Linden

Re: Generic links to resources in resource file to stay in tact during restore

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

You're never going to be able to do that.

Moodle cannot edit your PDF files to change the links. 

In reply to Howard Miller

Re: Generic links to resources in resource file to stay in tact during restore

by Louisa van der Linden -

Hopefully it never changes my files smile

The direct question is, does a site resource have a link of the format: currentCourse/file123.pdf

instead of: specificCourse/file123.pdf

In reply to Louisa van der Linden

Re: Generic links to resources in resource file to stay in tact during restore

by Ken Task -
Picture of Particularly helpful Moodlers

Think you can find out yourself ... is the 2018 site still up?   Go look at a link to a PDF file in the moodle itself.

And suggest looking at direct SQL queries of the DB for the 2018 server to find all PDF files contained in moodledata/filedir/

What one sees as a normal looking link is actually a DB query for a contenthashed file name in the sea of files located in moodledata/filedir/

moodledata/filedir is unique to each Moodle instance.

'spirit of sharing', Ken



In reply to Louisa van der Linden

Re: Generic links to resources in resource file to stay in tact during restore

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Short answer, no. 

It's just an id number into a database table. All the IDs change on restore so all your PDF (internal) links will continue to point to the 'old' location (or will just be broken if that doesn't exist). 

Deep linking into Moodle resources is a bad plan for this reason alone. 

In reply to Louisa van der Linden

Re: Generic links to resources in resource file to stay in tact during restore

by Louisa van der Linden -

Thanks all. Yes, it's simply just a lot of work for our content people. I appreciate the feedback, in agreement and I'm not an advocate for workarounds in configuration files if it's not an essential requirement.

Our content staff is clued up with Adobe and we have all the master PDF files offline, so that's no issue. We have multiple campuses in the same college who run similar courses on separate sites, hence all the work smile

We're actually busy transforming our content across all courses to move away from interactive PDFs.

Thanks again.


In reply to Louisa van der Linden

Re: Generic links to resources in resource file to stay in tact during restore

by Ken Task -
Picture of Particularly helpful Moodlers

+1 to what Howard said.

Even if one found a way with a horrific modification of config.php's wwwurl
variable OR htaccess rewrite rules one would still face the very same issue
when spinning up your 2020 instance.

One cannot keep the 2018 site up for ever ... OS updates as well as Moodle
version updates/upgrades to keep that site secure.

Me thinks, lot's of work ahead of ya.

https://forums.adobe.com/thread/2271275

https://www.wonderfulshare.net/how-to/how-to-update-and-replace-pdf-links-globally/

You'd have to extract all the PDF's in the 2018 site to a workstation where
you had the Adobe software to edit links in PDF's.  Extracting all pdf files would require a SQL query to find the contenthash of the file in /moodledata/filedir/ and when downloading/extracting, change the contenthash named file to something humanly understandable.

AND, prior to mass converting the PDF's

One would have to use a file system repository outside of Moodle such
as Dropbox, Google, other such that the URL's in the PDF's would never refer
to a Moodle's file system.

AND, the new links would have to point to directories ... rather than specific PDF
files, I would think.   'Collections' if you will ... like all the PDF's for a Course in Suicide Prevention in a Moodle to a directory ... "sp".  Would avoid using a year in the naming of directories.

'spirit of sharing', Ken