Dynamic URLs to Legacy Files

Dynamic URLs to Legacy Files

by Blaine Helmick -
Number of replies: 1

I have a number of courses that make extensive use of Legacy Files due to the relative pathing used in the HTML content. We use a URL resource to link the student to the root of the sections within the HTML which is working great.

The problem is when I backup the course from my dev server and restore it to my production server. The URL on my dev server looks something like this, /file.php/15/index.html

When I restore a package it keeps that URL the same even though the repository number it's restoring into is different. Therefore all of the URLs break and I have to go in and fix them all by hand.

So the question is this, is there a way I can use a dynamic variable in the URL that will always render to the current repository's number? I'd love to set my URLs to something like this: /file.php/@@REPO@@/index.html

Does such a feature exist? If not, does anyone have a suggestion as to how I can preserve links to legacy content in the backup?

Average of ratings: -
In reply to Blaine Helmick

Re: Dynamic URLs to Legacy Files

by Davo Smith -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

If you backup and then restore with the setting 'update course settings' (or is it 'overwrite course settings' - I don't have it in front of me at the moment), then the legacy course files are restored.

It is also possible, with a small modification to the backup code, to make sure that legacy course files are always restored (even when the rest of the course settings are not), but I've not got the code to hand, so I'll have to dig that out later.