LMSouq
moodle-core Open

Cleanest way to include urls in Moodle emails

FR
Frank Sebastià
1 month ago
3 views
Problem Description
I'd like to know which is the cleanest way to insert an url in an email sent by Moodle module. So far I'm using this formula, what IMHO I don't think is the cleanest way: $url = $CFG->wwwroot.'/mod/<mymodulename>/view.php?id='.$cm->id; The things I don't like here are: - Using $CFG->wwwroot - /mod/<mymodulename> needs to be provided always. (Assume here that I'm using a constant instead of a hardcoded string). I expected Moodle to have a function to provide this out of the box just when providing module script. I've tried moodle_url but this function doesn't provide the path to the php script when used this way: new moodle_url('view.php?id='.$cm->id); I just get: view.php?id=XX Thanks in advance.

AI-Generated Solution

Powered by LMSouq AI · GPT-4.1-mini

✓ Solution Ready
Analyzing problem and generating solution…
Was this solution helpful?
Back to Knowledge Base