Adding permanent links to sidebar

Adding permanent links to sidebar

by C. Kirill Sokolov -
Number of replies: 3
Hello,

I'd like to have several links appear on every major page in my Moodle site. E.g.,

How to contact TechSupport
Visit the Library
Submit a repair request

In many ways, the "Main Menu" that can be customized for the Front Page does the trick well, but the Main Menu does not appear further down in Moodle, i.e., on the course page (view.php?)

I suspect a well placed PHP echo command would do the trick, but I can't find the place. It would be even nicer if I could force the Main Menu to appear on the course page, as well.

Can anyone point me in the right direction?

PS: This is a GREAT product. With Moodle and other projects like it, I'm steadily moving all my school's resources to open source!

Kirill Sokolov
St Vladimir's Seminary
Average of ratings: -
In reply to C. Kirill Sokolov

Re: Adding permanent links to sidebar

by Mark Hughes -

Now let me preface my comment by saying that I have not tried this, nor do I have even a basic understanding of Moodle's architecture yet -- I have no idea if this hack will work.  With that said, here is my best guess of what needs to be done.

You'll have to edit three files

/moodle/course/format/topics/format.php
/moodle/course/format/weeks/format.php
/moodle/course/format/weeks/format.php

Open them up in an editor and look for the line that reads /// The left column ...

The easiest thing to do would be to hard code some echos or print() functions.

The more elegant solution would be to create your own sideblock using the functions deep in the heart of /courses/lib.php.

If you're new to PHP I'd recommend the hard code for now, as I've heard scuttlebut that all of the current html is going to be scrapped farily soon.  No sense in spending a whole lot of time in something that'll be gone in a week or two.

If you're the tinkering type, I took a quick look at the code and I believe a function in /moodle/course/lib.php called print_section_block is responsible for the side boxes.  Take a look at /moodle/index.php and see what function they're using to call up the menu and then just pop it into the course format.php pages. 

I hope that gets you started (and I hope it's not blantant lies)

Good luck!

In reply to Mark Hughes

Re: Adding permanent links to sidebar

by C. Kirill Sokolov -
Thank you, Mark, your message gave me the courage to go ahead. :)

I basically did what you suggested.  I created a chunk of code and placed it in social.php, weeks.php, and topics.php.  Incidentally, social.php seems to have less commenting though it is pretty straightforward to figure out.

I also added this to /index.html so that the links would be visible on the "front page."

I'm sure that there is a much more elegant way of doing this.  I bet other schools do / would want to do something similar to this, and wonder if somehow this could be a configuration option in the future, down the road... ?

The code below seems to properly prepare the side "blocks" that are used for "People" and other such, btw.

Kirill Sokolov

CODE FOLLOWS:

/// KIRILL: PRINT OUT SITE-WIDE LINKS BEGIN
print_side_block_start("Other SVOTS.EDU pages", $leftwidth, "sideblocklinks");
echo "<FONT SIZE = \"-1\"><P>";
echo "<A HREF = \"http://www.svots.edu\" TARGET = \"_external\">SVOTS Home</A><BR>";
echo "<A HREF = \"http://www.svots.edu/Library\" TARGET = \"_external\">Library</A>";
echo "</P></FONT>";
print_side_block_end();
/// KIRILL: PRINT OUT SITE-WIDE LINKS END
Average of ratings: Useful (1)
In reply to C. Kirill Sokolov

Re: Adding permanent links to sidebar

by Mark Hughes -
Hey, thanks for posting that code....I've got every intention of stealing it and using it sometime soon!  smile