You'll need to make a minor adjustment to the root index.php file, but the rest won't need to be touched. The script assumes that you have a set of categories for the headers and subcategories for the "accordion" list. Courses within these subcategories will be linked under this list. Any additional subcategories will also be displayed within this list.
See a video demonstration here
Download the code here
I'd greatly appreciate any comments or feedback you may have.
This would be super-amazing if it was a block and could replace/overlay the standard My courses block. It does seem quite large at the moment, perhaps collapse the accordions into three bars that would expand on mouseover, so that the course menu could be in the header, just above the breadcrumbs.
Interesting recent discussion about javascript here stuff, in case you didn't see it.
I'll give it a try when I've got some time next week.
When I click on the accordion it tries to link to
http://localhost/course/view.php?id=2
instead of
http://localhost/moodle/course/view.php?id=2
Please let me know how to fix it.
Thanks,
Barry
Thanks for the comments. I've updated the code to hopefully fix your issue, can you try downloading it again and let me know how you go?
Thanks,
Mark
thanks for the help, the links are not creating any errors now, but whenever I click on a subcategory they all take me to the same top category page (Miscellaneous) and all the courses are always visible and not collapsed. The menu doesn't expand or collapse at any time like in your video. I thought it was to do with my AJAX settings but I have enabled AJAX.
Is there another setting somewhere I need to change? I see Chen has the same problem.
Barry
Please see my reply to Chen (below) or give me a couple of days to update the archive. I forgot to include one important step.
Mark
For the moment it's just intended as a front page mod, but a header menu sounds like a great idea.
Thanks again,
Mark
Re: Front Page "Accordion" Course Menu worked in different way
thanks, Mark,
I am also expecting a such style headermenu.
I tried your great menu last night, it works well. But I can only see the header, no menu items was displayed in the list. Then I created some subcategories, and courses in the subcategory displayed in the list directly without mouse clicking .
Can you help me ?Thanks.
Re: Front Page "Accordion" Course Menu worked in different way
It seems I missed one important step that I didn't include in the readme. I'll update the file in the next couple of days, but for the moment you'll need to do the following:
In your theme's header.html file, within the <head> tags, include the following code:
<script>
$(document).ready(function(){
$("dd").hide();
$("dt a").click(function(){
if ($(this).parent().next().is(':visible')) {
$(this).parent().next().slideUp("slow");
}
else {
$("dd:visible").slideUp("slow");
$(this).parent().next().slideDown("slow");
}
return false;
});
});
</script>
This should enable the menu animations.
Let me know how you go.
Mark
I modified the code as you suggested, but it didn't work yet. I checked code in accordion_course_menu files and found that the file " jquery-1.2.6.min.js " is not referenced anywhere.Is that the problem?
Thanks.
Chen
Yes that should be referenced as well just above the previous entry in the header.html file, sorry I missed that line myself. Use the code below to replace the code I gave you in my last reply:
<script src="<?php echo $CFG->themewww .'/'. current_theme() ?>/accordion_course_menu/jquery-1.2.6.min.js"></script>
<script>
$(document).ready(function(){
$("dd").hide();
$("dt a").click(function(){
if ($(this).parent().next().is(':visible')) {
$(this).parent().next().slideUp("slow");
}
else {
$("dd:visible").slideUp("slow");
$(this).parent().next().slideDown("slow");
}
return false;
});
});
</script>
I just tried it with the new script added and it works beautifully!
Very cool. Thanks alot.
Barry
Re: Front Page "Accordion" Course Menu work well on FireFox
Thanks Mark,
It works well on FireFox now. Good idea.Thanks.
One more issue on IE7.0: course items are seperated with a blank block as high as the course item, where should be a white line only.
Chen
Re: Front Page "Accordion" Course Menu work well on FireFox
I've also updated the archive to include all the latest instructions.
Mark
Firstly..brilliant design.
I can't find anything on this in the forums so...go to the source.
I'm finding when I add more than 3 levels (eg. Induction/Officer Induction/Week 1/Day 1) the drop down effect doesn't work on the 4th level. Is there a limitation to the number of levels? Is there code I could add to enable the 4th level or am I just simply doing something wrong??
Thanks.
Thanks for the compliment. Right now it only works 3 levels deep. I tried to expand additional subcategories but I had issues with the parent category contracting as the subcategory expanded, which effectively hid everything. Given the way the Accordion format works, it only allows one menu item to be open at once, so it's quite difficult to open subcategories in the same way. I'm sure there's a solution, I just haven't had the time to work it out yet.
What I can do is provide you with some code that will change the method of expanding categories, so that more than one can be open at once. This will allow us to add an expandable menu within subcategories, but it means that other menus won't contract unless manually clicked.
How does that sound?
Mark
Simply replace your accordion_course_menu.php file with the one attached, and remove the code your previously added to your header.html file (we won't need to modify that again next time either).
Let me know how you go.
Mark
Ynt: Re: Front Page "Accordion" Course Menu (video inside)
Great menu. I like to use it. But multilanguage support is not working in the menu.
Thanks
Oktay
Re: Ynt: Re: Front Page "Accordion" Course Menu (video inside)
I'm not sure why multilanguage would not be working. It's simply pulling course names directly from the database. It appears as if Chen's menu is working fine. This may be something beyond my knowledge unfortunately. Can I see an example?
Mark,
This is a fantasic menu for what I am doing. The modification in the file attached here is exactly what I need. I did have an issue though in that the modified menu that allows sub-sub menus seemed to be viewing my courses as categories. I am not a developer, but I poked around a bit and saw the following line in the "//Expand sub-sub categories" section
<a style="color:#dddddd;" href="<?php print $CFG->wwwroot; ?>/course/category.php?id=<?php print $course_id5; ?>"><?php print $course_name5; ?></a>
When I changed this to read
<a style="color:#dddddd;" href="<?php print $CFG->wwwroot; ?>/course/view.php?id=<?php print $course_id5; ?>"><?php print $course_name5; ?></a>
It worked fine. Not sure if that is a bug or if it is just specific to how I am using it.
I am also seeing the issue where there is a big gap of white space between the courses. I noticed that someone else had mentioned this as well. Do you know what the issue would be ? I am seeing this on various versions of IE. I have not tried FireFox.
Thanks and regards,
Nigel.
Hello Mark,
Cracking piece of code. I'd like to use it through my moodle, I think the best way of doing this is to include it as an html block. Is it possible to help me with this?.
Sorry for the delay in response. The issue with an html block is that it does not allow php code, which we need in this case to extract information from the database. The only other solution is to create a standalone block, but that may take some time. I'll certainly update this post when I get a chance to create a block.
Mark
That seems like a very strange message. Is it possible that you are using any non-standard characters in your course names?
Hi Mark
Nothing out of the ordinary. I'm just trying this out on a test site at the moment. I've also tried viewing it on several machines, both at home and at work. I've followed your instructions, cut and pasted what needs cutting and pasting, double checked that everything matches. I downloaded the latest version yesterday (9th December 2008) so it should be pretty much up to date. The version of Moodle is 1.9.2 (Build: 20080711). The theme I'm using is Chameleon. I suppose I could try another theme when I get into work, but I don't see what difference that could make.
Re: Front Page "Accordion" Course Menu (video inside)
Re: Front Page "Accordion" Course Menu (video inside)
I know Zbysiu personally. He got round it by putting a number in front of the category. For example.
1. English
2. Maths
3. Science
Hope this helps
The order is controled by the SQL select statements.
You can modify the statements to sort either ascending or decending, based on any field in the course_categories table.
For example, the 'order by name ASC' part of the following select statement will cause the first level categories to be sorted in ascending order based on the course name.
$result = get_records_sql("SELECT * FROM {$CFG->prefix}course_categories WHERE parent = '0' AND visible = '1' order by name ASC");
Rob
Re: Front Page "Accordion" Course Menu (video inside)
In actual fact I am noticing the categories show up in the order created, even when I use the reordering tools in Course Categories?
This is a fantastic piece of work.
Soryry to be a pain but there's only one thing i want to do with it - can i stop the red boxes acting as hyperlinks? Just people click into them and get the much less attractive old category menu
Thanks a million
alan
Look for this line in the accordion_course_menu.php file:
<a style="color:#ffffff; display:block;" href="<?php print $CFG->wwwroot; ?>/course/category.php?id=<?php print $category_id; ?>"><?php print $category_name; ?></a>
Notice the "<a style=...", that's the link. What you can do is simply change that line to the following:
<?php print $category_name; ?>
Let me know if you have any trouble.
Worked great
thanks a million
Re: Front Page "Accordion" Course Menu (video inside)
It works fine with my installation locally but there is one problem and I was wondering if there is a way to solve it.
I've noticed that it only shows visible categories, sub-categories and courses. Even an administrator account can't see them in the menu.
In my site I have implemented some roles and hidden some courses and only one role can see them but no matter who is logged in, from admin to simple user, the menu cannot show these courses.
Is there a way around this or this is it and the menu only shows visible categories, sub-categories and courses when they are for everyone?
Thanks in advance,
Panos.
Re: Front Page "Accordion" Course Menu (video inside)
Is there any way that we can show this menu on some other page other than the first page of our moodle installation?
Thanks in advance,
Panos
Re: Front Page "Accordion" Course Menu (video inside)
Your first question may be possible but relies on other hooks being in place that I'm not familiar with at this time. It should be possible to display all hidden courses with some sort of "is user admin" function as the roles database is confusing to me
As for your second question, the front page and course pages use a different backend template, but it will be hard to add it to a single course without adding it to all other courses at the same time. The only other solution would be to create a new course format with this in place, but I haven't looked into that part of Moodle at all.
As you may guess this is more of a hack than a complete mod, but I will look into some of these suggestions in the new year.
Re: Front Page "Accordion" Course Menu (video inside)
They were exactly what I was expecting but I had to hear it from the creator
Non the less, great job. Keep it up.
Panos
Re: Front Page "Accordion" Course Menu (video inside)
how a can integrate the course menu in moodle 1.9.3+
please step per step
im interested in a fix for this myself, im getting similar gaps with IE, ill look in to it more tomorrow, if i find a solution myself ill post back, otherwise if someone finds how to eliminate the extra gaps please tell me
thanks
Alun
We have tested on this on several browsers and IE versions. The issues seems to be IE6 specific. We are just living with it on IE 6, since most of our users are using newer versions of FF.
Have you seen the "new and improved" version of this menu? It is much better for us and we will be updating to this new version - with some additional customization.
Rob
i fixed my problem, they now don't show the extra spaces i mentioned, also modified it to show courses that reside within the top category that don't have a sub-category drop-down menu to be in.
is the new and improved version the one from https://meine.tfh-bochum.de/lms/ or the modified one that can support sub-sub categories?
Hi,
I really like the Modified Accordion Course Menu that Alun has attached here, but it displays all courses and categories in one single column. How do I make it so each 'Master' category has its own column?
Also, when I click on the Sub Category, it dosen't stay open. How do I resolve this issue?
Thanks for your help.
Re: Front Page "Accordion" Course Menu (video inside)
I have installed Accordion Course Menu and I tried install Exabis e-portfolio 3.2.1 in mdl 1.9.3, and I have a problem.
When I "Add a View", "Your Items" can't incorporate to "View Design" (error: object don't allow this properties).
I think this is the problem. My header contains this lines:
<script src="<?php echo $CFG->themewww .'/'. current_theme() ?>/accordion_course_menu/jquery-1.2.6.min.js"></script>
This script is not campatible width exabis new view. Thanks for your help.
Regards.
Hi Mark,
I am quite new to moodle. I had installed the accordion course menu according to the "readme.txt" from accordion_course_menu" file. On the first part, the readme.txt says:
Edit your root index.php file and look for the following lines:
$frontpagelayout = $CFG->frontpage;
}
foreach (explode(',',$frontpagelayout) as $v) {
switch ($v) { /// Display the main part of the front page.
Insert the following code snippet between the "}" and "foreach" lines:
//Display Accordion Course Menu
include('./theme/'. current_theme() .'/accordion_course_menu/accordion_course_menu.php');
I had inserted red statement into my root moodle=>index.php. The second part of "readme.txt" is:
Edit your theme's header.html file and insert the following code within the <head> tags:
<script src="<?php echo $CFG->themewww .'/'. current_theme() ?>/accordion_course_menu/jquery-1.2.6.min.js"></script>
<script>
$(document).ready(function(){
$("dd").hide();
$("dt a").click(function(){
if ($(this).parent().next().is(':visible')) {
$(this).parent().next().slideUp("slow");
}
else {
$("dd:visible").slideUp("slow");
$(this).parent().next().slideDown("slow");
}
return false;
});
});
</script>
I inserted this script in between <head>"script here" </head>... something like dat shown below:
<head>
<?php echo $meta ?>
<meta name="keywords" content="moodle, <?php echo $title ?> " />
<title><?php echo $title ?></title>
<link rel="shortcut icon" href="<?php echo $CFG->themewww .'/'. current_theme() ?>/favicon.ico" />
<?php include("$CFG->javascript"); ?>
<script src="<?php echo $CFG->themewww .'/'. current_theme() ?>/accordion_course_menu/jquery-1.2.6.min.js"></script>
<script>
$(document).ready(function(){
$("dd").hide();
$("dt a").click(function(){
if ($(this).parent().next().is(':visible')) {
$(this).parent().next().slideUp("slow");
}
else {
$("dd:visible").slideUp("slow");
$(this).parent().next().slideDown("slow");
}
return false;
});
});
</script>
</head>
Are there anymore script that i needed to edit or i had left out because it dont seems to work on my moodle site.
Thanks for reading this.
I get this error: Module "accordion_course_menu" is not readable - check permissions
I have been keen to use this format but previous versions wouldnt work with our "Custom_corners" theme.
On my site each faculty is a Category, a few have subcategories, and all the subjects offered are courses within each categories.
Any chance you could tweak this so that instead of "a set of categories for the headers and subcategories for the accordion list" its based on categories with courses all in a single column - an accordion version of the myCourses block?
Has anyone managed to get it to display properly in IE 8 yet?
Thanks
Hi Guys,
I have moodle 1.9.4 running on my site. I have followed through the instructions for setting up accordion, and it works well with both chameleon and custom corners, i haven't decided which theme i like best yet. I have also followed the instructions for setting up accordion menu, and it also works well with both themes.
The problem is that when I am running accordion menu, accordion no longer works in any of my courses. As soon as I remove the php code from the header.html file, accordion works perfectly again.
Here is the relevant section of the header.html file:
<?php include('ui/chameleon.php'); ?>
<?php include("$CFG->javascript"); ?>
<?php if (strpos($bodytags, 'id="course-view"') !== false) include('acco/accordion.php'); ?>
<script src="<?php echo $CFG->themewww .'/'. current_theme() ?>/accordion_course_menu/jquery-1.2.6.min.js"></script>
<script>
$(document).ready(function(){
$("dd").hide();
$("dt a").click(function(){
if ($(this).parent().next().is(':visible')) {
$(this).parent().next().slideUp("slow");
}
else {
$("dd:visible").slideUp("slow");
$(this).parent().next().slideDown("slow");
}
return false;
});
});
</script>
Any help getting both up and running will be most appreciated.
As you said, it's an issue with the jquery file, probably a conflict with the other accordion course format. What i'd suggest doing is checking the header or configuration file within the accordion course format for a jquery reference, and using the same path in your header file for the front page course menu. That way there shouldn't be any conflict. The only thing is that I can't guarantee the front page accordion course menu will work.
The other option is to place the jquery reference for the front page menu in the header.html file's front page section. That way it shouldn't get called on any course page (it should be like this anyway, but i'm not sure if it is).
Let me know how you go.
Thanks for the reply Mark.
I had a look through the header.html file, and did some research on the net. The conflict was fixed by placing the call to the jquery script at the beginning of the <HEAD> tag, before any other js script is called. Both accordion and accordion menu work fine together now.
Paul.
inspired by the fluid style we've done a little mod you are maybe interested in...
now with jquery-1.3.2.js, some 'cross-browser-fixes' and a much smoother movement in IE6,7,8.
but: we've implemented a only one-column design
module: http://moodle.org/mod/data/view.php?rid=2898
demo-video: http://www.tfh-bochum.de/uploads/media/accordion.html
live system: moodle.tfh-bochum.de
regards,
ml
Re: Front Page "Accordion" Course Menu (video inside)
I'm tryiong to use this accordion http://moodle.org/mod/data/view.php?rid=2898
But My tree is the following:
Level
Topic
Execices
Activities
And so on...
It seems that it isn't possible to use this accordion with sub-sub categories.
I have tried many things but my php knowledges don't help me... So I ask you
Thank you
This forum post has been removed
Re: Front Page "Accordion" Course Menu (video inside)
How do I change this behavior?
Tieku
Re: Front Page "Accordion" Course Menu (video inside)
The course data is obtained from your database using a series of get_records_sql() function calls. If you look at the php code you will see the actual sql statement that is being used is enclosed in the () for these calls. Part of this sql is the "order by" statement. You can change this to order the returned results using any field you like. We might not be using the same version, but the version that I am using has the functiona calls on the following lines ...
49, 51
66, 70
131, 135
196, 200
Each pair of function calls is used to return results for a specific level (Top Category Level etc.)
Hope this helps.
Rob
Can someone explain how to apply the patch?
Thanks
Thankyou for this code - it worked brilliantly immediately and makes navigation a lot easier.
However I have more than 3 main categories. I was wondering if there was a way of forcing a maximum of 3 columns and getting the other main categories to sit above and below each other so users do no need to scroll across.
I have recently had this uploaded to moodle - the script has been added to the root index.php and the header section of the theme being used - however the accordion menu option is not showing up in the front page settings options.
The people who installed the plug in for me also have added a file accordion mod - is this meant to be in there...is there anyone who can help me??
I did install this menu module on my local for testing purpose.
But problem is menu only show on home not on other pages.
Can anybody help me to make it possible to show this menu on all other pages also not bound to only home page or front pages.
-----------------
Thanks
Re: Front Page "Accordion" Course Menu (video inside)
Nitesh,
The Accordion Course Menu is not a global setting. You will have to walk through the installation for each site/course you wish to use it on.
Re: Front Page "Accordion" Course Menu (video inside)
Does anyone know if this has been tested and works with 1.9.9?
I had done and installation on 1.8 that functioned flawlessly but attempting to repeat the process with 1.9.9 using the latest version of Firefox the menu does not appear and I received no errors.
Any assistance with this is greatly appreciated.
Re: Front Page "Accordion" Course Menu (video inside)
DOH!!! I have this working as expected now. I had copied the accordion_course_menu folder into the theme top level folder instead of into the theme I had currently selected.
So remember the accordion_course_menu gets copied to
theme X DO NOT COPY the accordion_course_menu here
[Your currently selected theme. ie. Custom Corners]
-> accordion_course_menu goes here
Hopes this helps someone else in the future. Also check the references in the Page Source for your browser, it will show you what it expects.
Cheers!
Any chance of getting a version of this that works with moodle 2.1?
I appear to have a new problem develop with the menu. Last summer we upgraded our server to 2008RC using IIS7. Network users are using IE9. This problem seems to only apply to people (teachers) who have been added since then. What happens is that the teacher tries to access a particular course of which they are either a course creator or admin by clicking the link in the menu. What then happens is that the course link does the opposite of what you would expect. Instead of taking the user to their course, the course link appears to move upwards and disappear behind the link above.
I'm perplexed and can't find a solution.
I should add that I'm running Moodle 1.9.12+ (Build: 20110726)