Hi there,
I'm using Moodle version 3.8.2, Adaptable theme and Course tiles format.
I've seen a lot about trying to add a simple 'back to course' button at the bottom of activity pages, or failing that, hiding the existing nav links that appear at the bottom of activity pages.
I can hide them - the jump-to activity dropdown list, and the link to previous/next activity nav-links, using CSS. To a very limited extent, CSS will allow me to replace the text (by using psuedo-element/'content') so 'Previous Activity" is replaced with 'Back to Course', but ultimately this isn't that useful because it's only CSS trickery and the link and the hover text from the initial nav link still remain.
I am trying (badly - I am a real amateur) to edit /course/classes/output/activity_navigation.php to create this back to course link. I know I can use CSS to hide parts I don't need, so I have only edited the top half of the _construct function, relating to 'previous module display' (see below, my changes in bold). The rest of the script remains the same:
/**
* Constructor.
*
* @param \cm_info|null $prevmod The previous module to display, null if none.
* @param \cm_info|null $nextmod The next module to display, null if none.
* @param array $activitylist The list of activity URLs (as key) and names (as value) for the activity dropdown menu.
*/
public function __construct($prevmod, $nextmod, $activitylist = array()) {
global $OUTPUT;
// Check if there is a previous module to display.
if ($prevmod) {
$linkurl = new \moodle_url($CFG->wwwroot.'/course/view.php?id=' .$this->page->course->id);
$linkname = "Back to Course";
if (!$prevmod->visible) {
$linkname .= ' ' . get_string('hiddenwithbrackets');
}
$attributes = [
'class' => 'btn btn-link',
'id' => 'prev-activity-link',
'title' => $linkname,
];
$this->prevlink = new \action_link($linkurl, $OUTPUT->larrow() . ' ' . $linkname, null, $attributes);
}
I have tried a number of different ways of expressing that url in bold, I've found different posts on 'getting a course id from an activity page', I've looked at renderers with links that work fine and tried to copy... I'm doing the wrong thing because no matter what I try, the id number always shows up as blank on my browser.
I have read so many blog posts on this but I can't crack it. Please can anyone help? Sorry if I'm not putting this across in the right way. Thanks v much!