Module didn't showing a link, but text like "label"

Module didn't showing a link, but text like "label"

oleh Éric Bugnet -
Jumlah balasan: 1
Gambar dari Documentation writers Gambar dari Plugin developers Gambar dari Translators
Hi all,

I hope you could help me...

I want to make a little module, but I don't want the result of the module on my course page to be a link to a new page showing the text, but all text directly included on my course... Like labels.

I want to make a "last messages" table to show the "x" last message from a forum, but connected with the users right.
- I don't want to make that in a bloc, I want the table in the course
- I can't use filter because filter use cache, and if cache isn't set to 0, all users will see the same table (I want each user can see only the messages they can access)
- I think module is the better option, but how to print result directly in the course ???


Thank for help
Éric
Rata-rata penilaian: -
Sebagai balasan Éric Bugnet

Re: Module didn't showing a link, but text like "label"

oleh sam marshall -
Gambar dari Core developers Gambar dari Peer reviewers Gambar dari Plugin developers
Hi,

I'm not sure of the answer but here are some suggestions.

1) You can copy the 'label' module to see how this works. I think it should be reasonably easy to make another module that behaves like 'label' in inserting some text on the homepage.

Unfortunately you will find that this data is cached even more aggressively than the filter textcache (permanently, until you edit something) so it won't work for your purposes.

2) I would suggest re-evaluating your requirements - make it a block.

3) If you really don't want to do that, there is one other option without editing Moodle core files. You can create a new course format, for example by starting from a standard format such as Weeks or Topics, make a copy of that folder and rename it, then add your code in the format.php somewhere. [note, this is a bit desperate, I wouldn't recommend it unless you want to make other more major changes to the course format too.]

4) One other thing to try might be to look at how Forum manages to do its 'unread message' count on the front page (which presumably is not cached too much). Is that a specific hack that only works for that one behaviour, or could you hook into that mechanism? Just a thought. (I don't know how this is done.)

5) A bit crappy since this is client-side - but you could implement this facility in JavaScript/AJAX. Have your label-like module insert the necessary JavaScript code. When it runs, the JS will then make an Ajax call to a php script you've written somewhere inside your module's directory, to get your forum information table or whatever it is, and add this to the page. The JS code will be cached but that's ok because it never changes - the data returned from the AJAX call will change.

--sam