Calling html_writer from a plugin class

Calling html_writer from a plugin class

by Simon Vart -
Number of replies: 0

Hello,

We are developing a plugin. We need to have a generic function that will output some html fragment.

To avoid doing include, we have created a classes folder, in which we have created a folder, and inside this folder, the class and the necessary function.

(The idea is to be able to call the function by using namespace instead of doing includes).

The class and the function are found, but html_writer is not defined. 

We tried the have the class extends /plugin_renderer_base or /core_renderer, without success.

What is the rules here to call html_writer in a plugin class ? Do we miss some logic somewhere ?


EDIT


After some thought, we figure that : 


- The class we created should call the renderer

- The html fragment should be inside this renderer

- (all html fragment should be in the renderer)


So, anywhere we would need this fragment, we call the class, which use the renderer via $PAGE->get_renderer('plugin_name');


Is that correct ?

Average of ratings: -