moodleou / moodle-mod_subpage

Subpage module allows you to add Moodle activities onto inner page within course
21 stars 15 forks source link

Idea: include subpage title in breadcrubms #18

Closed pavelsokolov closed 7 years ago

pavelsokolov commented 7 years ago

When you go to a subpage and click on an activity in it you get this: Dashboard > Courses > Course category > Course name > Activity or resource in subpage

But it would be super handy to get this: Dashboard > Courses > Course category > Course name > %SUBPAGE TITLE% > Activity or resource in subpage

sammarshallou commented 7 years ago

Yes it would and we do have it working like that here.

The problem is that breadcrumbs are created by the theme and cannot be affected by a module (that isn't displaying the current page) such as subpage. In other words if you're looking at a forum page and it shows breadcrumbs, there is no way I'm aware of for the subpage module to modify those breadcrumbs, because Moodle doesn't really 'know' that the subpage owns the forum and should be in the breadcrumbs.

You can achieve this feature - we have it in our system - but only by using a custom theme, including a renderer function which modifies the breadcrumbs by taking into account subpages. So unfortunately I don't think it's possible to do this just as part of the subpage module.

I just looked at the code to do this in our theme and it's kind of horrible and not very easy to just copy and paste into anyone else's code, however if you're interested I can put the code somewhere you could see it...

pavelsokolov commented 7 years ago

I expected it to be quite sophisticated ;) if you don't mind, i would like to take a look on the code to see if i can reimplement it in our theme. Thanks!

sammarshallou commented 7 years ago

Sure. I copied out what I think is the relevant code and stuck it in pastebin - note you're going to want to get rid of a bunch of this code because it does things you aren't going to want. Hopefully I caught all of the changing-breadcrumbs-for-subpage part though! Fingers crossed...

http://pastebin.com/kpfKniDD