Glossary categories block

Glossary categories block

by Mark Berthelemy -
Number of replies: 16
Hi everyone,

I'm trying to develop a block that picks up the categories from a glossary and displays them, with hyperlinks to display those categories within the glossary. Something like this:

Glossary name: Living things

Animals (hyperlinked to the glosssary to show only that category)
Plants (hyperlinked to the glosssary to show only that category)

My PHP writing skills are minimal, although I can read the gist of simple PHP code. So I thought I'd start with the Random Glossary entry block. But then I got stuck, because that block is far more complex than I need, and I'm not sure which bits I can safely cut out.

Could someone give me a start on this that I can take forward...?

Thanks,

Mark

Average of ratings: -
In reply to Mark Berthelemy

Re: Glossary categories block

by Helen Foster -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
Hi Mark,

If you've not done so already, perhaps you could read Jon's excellent Step-by-step Guide To Creating Blocks. smile
In reply to Helen Foster

Re: Glossary categories block

by Mark Berthelemy -
Hi Helen,

Yes, I'm working my way through that. It's certainly an excellent introduction to blocks. I'm realising that I need to get my head round the PHP syntax though... sad It's a bit different from the languages I was brought up on.

Oh well, I do like to learn new things. Hopefully soon I'll have a block to show for it!

Cheers,

Mark
In reply to Mark Berthelemy

Re: Glossary categories block

by Mark Berthelemy -
Hi everyone,

With a lot of help from Jon's blocks documentation and a rather ruthless hacking around of the random quotes block I'm presenting a rough, but working Glossary Categories block.

I'm sure there's a lot that can be done to tidy it up. There are bits of code that I've put in without really being sure what they do. But it seems to work.

Any comments gratefully received.

Mark
In reply to Mark Berthelemy

Re: Glossary categories block

by Mark Berthelemy -
Hi again,

Just in case you're wondering what this does, I've attached a screen shot.

It picks up the categories from a selected glossary in that course, and displays them as hyperlinks to those categories, with the numbers of entries in that category.

The main work that needs to be done (I think) is error-trapping and general tidy up of the code. I'm not exactly sure how the data is being passed among all the variables and arrays, but I'm sure it could be made simpler.

If anyone can see any glaring issues that means I shouldn't deploy this on a production server, please let me know.

Cheers,

Mark
Attachment glossary_categories.gif
In reply to Mark Berthelemy

Re: Glossary categories block

by Bob Puffer -
This looks very interesting -- the ideas pop out all over, especially in Language Learning.  What a boon it would be if a glossary permitted multiple categorization of entries.
In reply to Bob Puffer

Re: Glossary categories block

by Mark Berthelemy -
Hi Bob,

But it can... Just use CTRL-click to select more than one category.

One thing glossaries can't do is provide a hierarchical categorisation. So you couldn't have:

French
... Verbs
... Nouns
German
... Verbs
... Nouns

And you can't yet search within a specific category.

This categories block will pick up and count things that appear in more than one category. So...

Fruit (1)
Vegetables (1)

might be pointing to the same entry (eg. tomatoes)

Mark


In reply to Mark Berthelemy

Re: Glossary categories block

by Bob Puffer -
Thanks for the heads-up on picking multiple categories.
In reply to Mark Berthelemy

Re: Glossary categories block v0.2

by Mark Berthelemy -
Hi everyone,

I've redone this block in a proper list format. The footer contains a link to the glossary (although I couldn't work out how to get the glossary name automatically, so the link is hard-coded text "View complete list").

I've also tidied things up a lot so there aren't a whole load of redundant variables. The version number is now correct (v0.2).

I still need to include a language file.

As always - any comments, please let me know.

Mark
In reply to Mark Berthelemy

Re: Glossary categories block v0.2

by Mark Berthelemy -
Hi, me again.

If you want to see the block in action go to: www.nationalstrategiescpd.org.uk - it's on the home page.

Cheers,

Mark
In reply to Mark Berthelemy

Re: Glossary categories block v0.2

by Helen Foster -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
Hi Mark,

Just wanted to say that both your block and your Moodle site look very cool! approve
In reply to Helen Foster

Re: Glossary categories block v0.2

by Chardelle Busch -
Picture of Core developers
Hi Mark,

This block might be something that would work for me. I have created a "personal journal" glossary, and with this block, I could create a category for each course, hmmm....I'll have to give it a try. Can you add this block for your site FAQ to a course?
By the way. I see you have deleted the activity index from your breadcrumbs, however you now have an extra >>. I am assuming you have deleted the activity name from the navigation on the view.php for each activity, if so, you also need to delete the -> that comes after it.
In reply to Chardelle Busch

Re: Glossary categories block v0.2

by Mark Berthelemy -
Hi Chardelle,

Yes, it works fine within a course. I've realised that I've not put in any code to test whether the glossary is visible or not, so it will display the categories regardless. (Something to work on I think).

I know that the extra >> appears on items linked from the home page. I've put Mike Churchward's catnav and nav hacks into the header.

See:
http://moodle.org/mod/forum/discuss.php?d=24090#113932
http://moodle.org/mod/forum/discuss.php?d=16850

These remove the activities from the breadcrumbs and replace them with course categories & sub-categories... A much more intuitive navigation approach... perhaps?

Mark
In reply to Mark Berthelemy

Re: Glossary categories block v0.2

by Chardelle Busch -
Picture of Core developers
I see, I didn't realize you had cat and subcat in the breadcrumbs.  Hmm, I wouldn't have thought of doing it that way since it seems like the course cat and subcat really only come into play when a student is enrolling into the course.  After that, it doesn't seem necessary to me that they would need to be in the breadcrumbs.  But it can get tricky to sort everything out.  Are use using Mike's course programs block also?  It shows course links via category.

Helen posted some code a while back that I use to take the module/activity index page out of the breadcrumbs.