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 -
Number of replies: 7
Снимка на Core developers Снимка на Documentation writers Снимка на Peer reviewers Снимка на Plugin developers Снимка на 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

In reply to Mary Evans

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

от Darko Miletić -
In reply to Darko Miletić

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

от Mary Evans -
Снимка на Core developers Снимка на Documentation writers Снимка на Peer reviewers Снимка на Plugin developers Снимка на 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

In reply to Mary Evans

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

от Gareth J Barnard -
Снимка на Core developers Снимка на Particularly helpful Moodlers Снимка на 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

In reply to Gareth J Barnard

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

от Mary Evans -
Снимка на Core developers Снимка на Documentation writers Снимка на Peer reviewers Снимка на Plugin developers Снимка на 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

 

In reply to Mary Evans

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.

In reply to Darko Miletić

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

от Gareth J Barnard -
Снимка на Core developers Снимка на Particularly helpful Moodlers Снимка на 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.