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?

Mary Evans -
Erantzun kopurua: 7
Core developers-ren irudia Documentation writers-ren irudia Peer reviewers-ren irudia Plugin developers-ren irudia Testers-ren irudia

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

Puntuazioen batez bestekoa: -
Mary Evans(e)ri erantzunda

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

Darko Miletić -
Darko Miletić(e)ri erantzunda

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

Mary Evans -
Core developers-ren irudia Documentation writers-ren irudia Peer reviewers-ren irudia Plugin developers-ren irudia Testers-ren irudia

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

Mary Evans(e)ri erantzunda

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

Gareth J Barnard -
Core developers-ren irudia Particularly helpful Moodlers-ren irudia Plugin developers-ren irudia

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

Gareth J Barnard(e)ri erantzunda

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

Mary Evans -
Core developers-ren irudia Documentation writers-ren irudia Peer reviewers-ren irudia Plugin developers-ren irudia Testers-ren irudia

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

 

Mary Evans(e)ri erantzunda

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

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.

Darko Miletić(e)ri erantzunda

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

Gareth J Barnard -
Core developers-ren irudia Particularly helpful Moodlers-ren irudia Plugin developers-ren irudia

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.

Gareth J Barnard(e)ri erantzunda

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

Darko Miletić -

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