Is it possible to create a renderer based on a mod lib.php function?

Is it possible to create a renderer based on a mod lib.php function?

oleh Mary Evans -
Jumlah balasan: 7
Gambar dari Core developers Gambar dari Documentation writers Gambar dari Peer reviewers Gambar dari Plugin developers Gambar dari Testers

Hi,

I am trying to remodel the forum layout that appears to be set in mode/forum/lib.php/

If I make direct changes in that file the forum displays just like I want it to.

However I cannot fathom how to get it into a theme renderer. 

Can anyone shed some light on it before I go bonkers! LOL

Cheers

Mary

Rata-rata penilaian: -
Sebagai balasan Mary Evans

Re: Is it possible to create a renderer based on a mod lib.php function?

oleh Darko Miletić -
Sebagai balasan Darko Miletić

Re: Is it possible to create a renderer based on a mod lib.php function?

oleh Mary Evans -
Gambar dari Core developers Gambar dari Documentation writers Gambar dari Peer reviewers Gambar dari Plugin developers Gambar dari Testers

Yes I did, thank you, but in this case nothing is working as I had hoped.

If I alter and makes changes to

moodle / mod / forum / lib.php > 

The layout for the forum looks and works as I would like it to. So I need to find a solution to convert that section of the mod/forum/lib.php > function forum_print_post into a renderer.where NO renderer exists!

It is so frustrating.

I'm plodding through some more files that I found and it may just be a matter of not knowing enough about the process for what I want to do.

Teach yourself is hard work!

Thanks

Mary

Sebagai balasan Mary Evans

Re: Is it possible to create a renderer based on a mod lib.php function?

oleh Gareth J Barnard -
Gambar dari Core developers Gambar dari Particularly helpful Moodlers Gambar dari Plugin developers

Hi Mary,

Can't be done unless the code is converted into a renderer in core.  lib.php is just a collection of global functions and thus not even OO but 'functional', therefore no benefits of being able to override as its a 'function' and not a 'method'.

Mod forum has a renderer, so it would be possible to move the function into that file and update all the places that call it.  But as said, this would be a core change.  Then you would be able to override it in a theme with an extending class.

Cheers,

Gareth

Sebagai balasan Gareth J Barnard

Re: Is it possible to create a renderer based on a mod lib.php function?

oleh Mary Evans -
Gambar dari Core developers Gambar dari Documentation writers Gambar dari Peer reviewers Gambar dari Plugin developers Gambar dari Testers

Thank-you Gareth for confirming what I was beginning to suspect...

Pity because the reorganised HTML within that function would look and work great in a theme.

It might be a better solution to open a tracker for it and suggest it as an "Improvement".

Many thanks for your time.

Cheers

Mary

 

Sebagai balasan Mary Evans

Re: Is it possible to create a renderer based on a mod lib.php function?

oleh Darko Miletić -

Nothing prevents you from adding custom javascript into your theme that can detect when page is displaying forum an rewrite html in any way you need.

Sebagai balasan Darko Miletić

Re: Is it possible to create a renderer based on a mod lib.php function?

oleh Gareth J Barnard -
Gambar dari Core developers Gambar dari Particularly helpful Moodlers Gambar dari Plugin developers

No worries Mary, I'm glad it helps.

 

With JavaScript, yes it could work but it would be a nasty hack.  The code would probably run after Dom ready and thus there would be the loading 'flash' as the structure was re-written = yuck!  Far better to have the ability to solve the problem elegantly and properly.

Sebagai balasan Gareth J Barnard

Re: Is it possible to create a renderer based on a mod lib.php function?

oleh Darko Miletić -

I agree that it is not ideal solution but other than modifying core code there is nothing else to do.