Navigation block

Navigation block

by Michael Penney -
Number of replies: 13

Hi all, one of our programmers, Jeff Graham whippled up a nice little block for navigtating courses with lots of sections/weeks.

It takes the first few lines of the section summary and puts in a as a link that maximizes that section.

See it & get it here http://learn.humboldt.edu/course/view.php?id=21&topic=2

Drop it in blocks and the lang file in lang to install. Backup everything first, of course.

Average of ratings: -
In reply to Michael Penney

Re: Navigation block

by Jean-Pierre Pawlak -
Excellent!
Just what we were searching for.

We get a warning though:

Warning: array_sum(): The argument should be an array in /home/hgibi61/public_html/moodle/blocks/moodleblock.class.php on line 209

I did a search on the forum. Does the block need the following string to function correctly?

function applicable_formats() {
return array('site' => true);



In reply to Jean-Pierre Pawlak

Re: Navigation block

by Jean-Pierre Pawlak -

The applicable formats have to be (of course)

return array('topics' => true);
return array('week' => true);

In reply to Jean-Pierre Pawlak

Re: Navigation block

by Jeff Graham -
Thanks for the code that worked perfectly.

I followed what the template suggested and used.
 
function applicable_formats() {
// We want our block to be available ONLY in weeks and topics format:
return COURSE_FORMAT_WEEKS | COURSE_FORMAT_TOPICS;
}

Any idea when the API changed?
In reply to Jeff Graham

Re: Navigation block

by John Papaioannou -
Hi Jeff,

The API changed just before the 1.4 release. There is a discussion in the "Blocks" forum, which ends in this informative post. The correct way to do the block with the new API is:

return array('weeks' => true, 'topics' => true);

Sorry for not updating the sample code and causing this trouble. As they say, the greatest sin of programmers is that they just like to code. wide eyes

Jon
In reply to John Papaioannou

Re: Navigation block

by Jeff Graham -
That's okay as I would have still run into the same problem as far as the sample code is concerned. This block was initially created for 1.3 and when we dropped in our 1.4 test installation it choked up at the applicable_formats.

Thanks for the info
In reply to Michael Penney

Re: Navigation block

by Simon Reynolds -
Don't forget to rename the folder nav14 to nav or you will get a file unreadable warning. (took me 20 minutes to work this out smile )
In reply to Simon Reynolds

Re: Navigation block

by Michael Penney -
Sorry about that Simon! I (not Jeffsmile renamed it nav14 to keep it straight from the older version as the blocks api got changed between 1.3 and 1.4. I'll get that fixed on the download, we also have a few more bug fixes having to do with unusual characters in the topic name.
In reply to Michael Penney

Re: Navigation block

by Gustav W Delius -
I find this block very useful. I would like to update it so that it works in Moodle 1.5 and then put it into contrib CVS. Is that o.k.?
In reply to Gustav W Delius

Re: Navigation block

by Sigurdur Jonsson -

Hi there,

Just wondering if this block has been updated for 1.5?

regards,

S.Fjalar

In reply to Sigurdur Jonsson

Re: Navigation block

by Michael Penney -
Yes, in CVS/contrib/nav/nav15.

I also updated xtree (contrib/tree) which I like better than nav nowsmile.
In reply to Michael Penney

Re: Navigation block

by A. T. Wyatt -
I am curious about why the navigation block disappears when you change themes.  Each time I change the theme, I have to reset the block.  This is not difficult, but it puzzling! thoughtful (I am using 1.5 stable on my tabletPC)