Re: Section Links Block to Show Topic Names Instead of Numbers
Re: Section Links Block to Show Topic Names Instead of Numbers
However, if you don't like that block, you can do what you want by editing blocks/section_links/block_section_links.php. We only use the "topics" course format, so I'm not sure how you'd do this with "weeks", but hopefully this will be helpful for you anyway...
This goes in the get_content() function inside the else if ($course->format == 'topics') part.
First add:
$topictitles = get_records('course_sections','course',$this->instance->pageid,'', 'section,summary');
Then change $text = '<ol class="inline-list">' to $text = '<ol class="list">';
Inside the for loop, change what comes after the $style = ($isvisible) ? '' : ' class="dimmed"';
$displaytitle = trim(strip_tags($topictitles[$i]->summary));
if (!empty($displaytitle)) {
if ($i == $highlight) {
$text .= "<li><a href=\"$link$i\"$style><b>{$displaytitle}</b></a></li>\n";
} else {
$text .= "<li><a href=\"$link$i\"$style>{$displaytitle}</a></li>\n";
}
Re: Section Links Block to Show Topic Names Instead of Numbers
Is there an easy way to get it to show the section links box on the left all the time? I want to act as a navigation bar. Thanks again!
Re: Section Links Block to Show Topic Names Instead of Numbers
Re: Section Links Block to Show Topic Names Instead of Numbers
e.g. <h1>Unit 1 - the first section</h1>
As long as you follow this, the following should work.
As before, edit block_section_links.php in the /blocks/section_links directory
Add summary to the sql select in the get_content() function.
$sql = "SELECT section, visible, summary
FROM {$CFG->prefix}course_sections
WHERE course = $course->id AND
section < ".($course->numsections+1)."
ORDER BY section";
Below the select comment out line:
$text = '<ol class="inline-list">';
then add line
$text = '<ol class="list">';
Lastly, insert the following code immediately after code line
$style = ($isvisible) ? '' : ' class="dimmed"';
The code to insert is:
$getsummary = $sections[$i]->summary;
$bits1 = explode("</h1>", $getsummary);
$bits2 = $bits1[0];
$bits3 = explode("<h1>", $bits2);
$displaybit = $bits3[1];
// the following is optional extra code to keep each list entry to 30 chars.
// if the lenth is over 30 chars, it displays the first 27 and then three dots...
if (strlen($displaybit) > 30)
{
$displaybit = substr($displaybit,0,27) . "...";
}
Re: Section Links Block to Show Topic Names Instead of Numbers
My section block disappeared from my course 1.9.4 and I am seeing how to get it back.
In another course on the same site, I created an html block and then created himl links to the course topics. No code tweaks, and it allowed me to display any name and in any order I wanted.
The link looked something like:
<a href="http://localhost/course/view.php?id=4#section-1"> 1. Definitions</a><br /><a href="http://localhost/course/view.php?id=4#section-2">
I think the sections # are only unique in the context of each course (ie with each id=X).
Hope this helps you and others. Best Chris
Re: Section Links Block to Show Topic Names Instead of Numbers
Thank you, Chris! I had a request from a client to display something other than "1, 2, 3,..." . I am SO GLAD you posted this suggestion. I was dreading the idea of code modification...
The HTML block took 3 minutes to create, it works perfectly, and is more flexible than the code hack (I added "click to go directly to a topic" and "alternatively, you can scroll down").
I love simple solutions! Thanks again. Penny
Re: Section Links Block to Show Topic Names Instead of Numbers
Hi Jenny,
It doesn't work in my Moodle 2.3. The strings changed in this version?
Thanks
Adriane
Re: Section Links Block to Show Topic Names Instead of Numbers
I'm glad that I found this discussion. Is there a solution for Moodle 2.4.5? thanks!
Re: Section Links Block to Show Topic Names Instead of Numbers
Create a custom HTML block, type out your "table of contents" and for each item in your list add a hyperlink to each corresponding section (the hyperlink should be #section-1, #section-2, etc.
Re: Section Links Block to Show Topic Names Instead of Numbers
This is of course possible. But think of doing this for 500 courses.
The course menu block is a plugin that does a great job.
See http://docs.moodle.org/26/en/Course_Menu_block and https://moodle.org/plugins/view.php?plugin=block_course_menu
-Derek