Category in navigiation?

Category in navigiation?

Darren Smith -
回帖数:22

In a course, in the navigation on the top left (are they called breadcrumbs?) I get something like:

mysite >> course

What I would really like is

mysite >> category >> subcategory >> subcategory >> course

Is there a way of doing this?

平均分:Useful (1)
回复Darren Smith

Re: Category in navigiation?

Melinda Kraft -
I don't know if there is a way, but I agree with you. I'd like to see the category in the breadcrumb trail. Even though you can click it again from the course list, it makes overall site navigation more intuitive, I think, to have it in the breadcrumbs, too.
回复Darren Smith

Re: Category in navigiation?

Barron Koralesky -

I agree as well, I think it would be useful and would provide more intuitive navigation to have the category in the breadcrumbs.
回复Barron Koralesky

Re: Category in navigiation?

Mary Kaplan -

It never occurred to me, but I agree it would be very useful. I am forever going back and forth between pages to get to other categories.

--Mary

回复Darren Smith

Re: Category in navigiation?

Mike Churchward -
Core developers的头像 Plugin developers的头像 Testers的头像
It just so happens that I have just what you need. I use this on one my sites.

Here's a snippet of code (attached) you can use in your theme's 'header.php' to do just that.

To use it, you will need to modify the 'header.php' file of whatever theme you want to use. I suggest copying the original file to a safe place, just in case.

Look for the line:
    '<?php if ($navigation) { // This is the navigation table with breadcrumbs ?>'.

It should be at line 40, or thereabouts. Insert this block of code just after that line and you should have what you want.

mike

回复Mike Churchward

Re: Category in navigiation?

Melinda Kraft -

Thanks, Mike! That's just what I needed.

For the record, my header file is header.html, not php, but putting the php code in worked just fine.

A note to others - Mike has two lines of code you can swap out by swapping the comment (//) markers that lets you decide if you want the link "course categories" included in your breadcrumb trail.

回复Melinda Kraft

Re: Category in navigiation?

Mike Churchward -
Core developers的头像 Plugin developers的头像 Testers的头像
Oops. You're right. It should be 'header.html'.
回复Mike Churchward

Re: Category in navigiation?

Darren Smith -
Thanks for this. Another time saver! You are going to have me working super-efficiently by the time we are finished big grin

As there is an option for switching it off does anyone important reading this feel it could go into 1.5 ???
回复Darren Smith

Re: Category in navigiation?

Mike Churchward -
Core developers的头像 Plugin developers的头像 Testers的头像
Hi Darren -

The option doesn't actually switch it off, it just controls whether you want the 'course categories' page in the breadcrumbs or not.

As to including it in 1.5, this is a 'hack' and would probably be best put into the code in a different way. The navigation is set in the library 'print_header' function - this is where it would be best to place this type of change permanently. You would need to make a 'new feature' request to have it introduced into the base Moodle.

The hack just recreates the nav before writing it. If you want it preserved, make a copy of the theme directory, give it a new name for your site and modify it. That way, updates won't obliterate the hack.

mike
回复Mike Churchward

Re: Category in navigiation?

Ger Tielemans -

Very nice, at last a real breadcrumb bar!

 (I like your option to show/not show the course categories!)

In my version the bar breaks into two bars ( before the first subcategory)
Can I prevent that?

回复Mike Churchward

Re: Category in navigiation?

Darren Smith -
Thanks for the reply and the explanations.

I have added it as a feature request as Bug #2347 and I have voted for it cool
回复Melinda Kraft

Re: Category in navigiation?

daniel ginerman -
oh, I very liked the feature...!
I added the code provided by Mike to my header.html
and swapped the // comment to have the "$nav=$navigation" uncommented (actually, I tried both swap options)
but everything remains the same... the effect doesn't occur
any good idea why it isn't working for me?
my site is www.eduplanet.net
thanx,

daniEl
回复daniel ginerman

Re: Category in navigiation?

Tony Delahunty -

One little bug in this feature, as distributed here: you need the top frame name in the breadcrumb trail links.    A cleaner coding of this is still needed, but you can get it functioning just by hardcoding in the frame name to your hack as below:

        if (is_object($course)) {
            $nav = $navigation;
            $cattree = get_record("course_categories", "id", $course->category);
            $linkcss = $cattree->visible ? "" : " class="dimmed" ";
            $nav = "<a $linkcss title="".htmlspecialchars($cattree->description)."" "
                  ."target="_top" href="$CFG->wwwroot/course/category.php?id=$cattree->id">$cattree->name</a> -> "
                  .$nav;
            while ($cattree->parent) {
                $cattree = get_record("course_categories", "id", $cattree->parent);
                $linkcss = $cattree->visible ? "" : " class="dimmed" ";
                $nav = "<a $linkcss title="".htmlspecialchars($cattree->description)."" "
                      ." target="_top" href="$CFG->wwwroot/course/category.php?id=$cattree->id">$cattree->name</a> -> "
                      .$nav;
            } 

回复Tony Delahunty

how to display the course's full bame, (not the short)

Noureddine Elzaatari -
hello all,

is there a way to display the course's full name name instead of the short name ?

thank you for any gudelines, help, or suggestions

Regards,

Noor
回复Mike Churchward

Re: Category in navigiation?

Brian Maynes -

Does anybody have code for doing this in 1.7.1?

I would like to see:

Site > Category > Sub-category > Course > Activity

when I am in a course/activity, but it reverts to:

Site > Course

when you click on the course.

The instructions provided don't seem to be valid in 1.7.1 because of code changes and the fact that the navbar is containd within a <div> now. Any help?

Thanks.
Brian

回复Brian Maynes

Category in navigiation?

Diwakar Moorthy -
I have changed the header.html file, but i have added a main menu block in front page. i have added a resource(web page) there. when i click on that i get as
moodle>> >> test(resource name)

is there anyway i can remove it.

thanks
diwakar
回复Brian Maynes

Re: Category in navigiation?

Tom Phethean -
I am having the same problem upgrading from 1.6 to 1.9 - the $navigation is now returned as an array, not as a string, so the code doesnt work.

I've been wracking my brains trying to work it out but can't get my head around it - does anyone know if there is a fix for 1.9?

Thanks
Tom
回复Tom Phethean

Re: Category in navigiation?

删除的用户 -

Can't solve your $navigation problem exactly, but hopefully you followed all the steps in converting your db to utf8 before the upgrade AND hopefully you did a stepped upgraded from 1.6 to 1.7 then to 1.8 then to 1.9.

I just recently upgraded from 1.6 to 1.9 (did 1.7 then 1.8 first) and have no noticeable problems.

See this link for details on upgrade:

http://moodle.org/mod/forum/discuss.php?d=95886

回复删除的用户

Re: Category in navigiation?

Tom Phethean -
Hi Jeff, thanks for your reply. Fortunately 1.6 was our first Moodle version, and it was setup as utf8 from the word go - saved us some time in the long run!

I didnt do a stepped upgrade, but everything seems to be working ok, except for the custom code posted above for displaying the categories in the navigation (which makes sense as it is no longer passed across as a string).

I was really wondering if Mike Churchwood had an updated version of this code...

微笑
回复Tom Phethean

Re: Category in navigiation?

Andrea Cianfanelli -
yep, it seems that in 1.9.* the $navigation became an array...
I need to change each occurrence of the course short name to "course index", but my php is pretty rusty...