Is there a variable for the link that goes directly to the course?
eg something like $a->courselink?
You might be looking for:
global $CFG;
$courselink = $CFG->wwwroot . "/course/view.php?id=" . $course_id;
Stephen Mc Guinness
Enovation Solutions
Thanks Stephen, I am not quite good enough at the syntax to get what you are saying:
Goal it to have link to course in welcome to course email, thanks.
You are correct that the variable does not exist. However what you can do is either create the URL on the fly using the above method within the PHP code or simply add the link to the email text as, and please correct me if I am wrong, you appear to be wanting to do.
If you are concerned about the welcome course being updated and its unique course ID getting changed, you can also reference it using the course's shortname. E.g. if the shortname for the welcome course is "welcome" the URL would look something like
http://my.site.com/course/view.php?name=welcome
The course shortname needs to be unique in any case, but this also allows you to have a new course which you can swap in by changing the shortname without having to then update the email text.
Hope this helps
Derick
Hi Alan,
The language string for the course welcome email (in 1.9) is:
$string['welcometocoursetext'] = 'Welcome to $a->coursename!
If you have not done so already, you should edit your profile page so that we can learn more about you:
$a->profileurl';
I that case $a is an object that is being passed as a parameter to the get_string call which is retrieving the welcometocoursetext language string.
You need to locate the get_string call and add your course link to the object which is passed as a parameter to that call.
In Moodle 1.9 the call to get_string is around lines 4711 - 4718 in lib/moodlelib.php
4711 if (!empty($course->welcomemessage)) {
4712 $message = $course->welcomemessage;
4713 } else {
4714 $a = new Object();
4715 $a->coursename = $course->fullname;
4716 $a->profileurl = "$CFG->wwwroot/user/view.php?id=$user->id&course=$course->id";
4717 $message = get_string("welcometocoursetext", "", $a);
4718 }
You need to modify that code to add your course link:
4711 if (!empty($course->welcomemessage)) {
4712 $message = $course->welcomemessage;
4713 } else {
4714 $a = new Object();
4715 $a->coursename = $course->fullname;
//Add the course link to $a so it can be used in the language string
$a->courselink = "{$CFG->wwwroot}/course/view.php?id={$course->id}";
4716 $a->profileurl = "$CFG->wwwroot/user/view.php?id=$user->id&course=$course->id";
4717 $message = get_string("welcometocoursetext", "", $a);
4718 }
$a->courselink would then be available in the language file for you to use in your modification of the course welcome email
Stephen Mc Guinness
Enovation Solutions