Roundcube Community Forum

Third Party Contributions => API Based Plugins => Topic started by: sago on December 14, 2019, 09:35:12 AM

Title: create html in on plugin and show it in Another
Post by: sago on December 14, 2019, 09:35:12 AM
Hi there,

I'm creating a captcha plugin in a plugin, and I need to display its html in another plugin, How can I do that, there is a way through rc api?

thanks
Title: Re: create html in on plugin and show it in Another
Post by: JohnDoh on December 15, 2019, 04:44:04 AM
There are a few different ways you could do it depending on exactly what you want.

Option 1) If you maintain all 3 plugins and they will always work together then instantiate one plugin class from the other and call the method you want to generate your captcha code.

Option 2) Custom plugin hook. Your captcha plugin could attach to an event like `show_my_captcha` and your other plugin could trigger this hook.

Option 3) The render_page` hook. In your captcha plugin you could listen for the render_page hook and insert the HTML into the response.
Title: Re: create html in on plugin and show it in Another
Post by: sago on December 16, 2019, 04:06:53 AM
thank a lot for your feedback,

I tried to go for 'render_page' hook, and it seems fit my case, only one more question..

I've seen, debugging code, that the html that I'm trying to fetch, is inside $this->rcmail->plugins->output['TEMPL....'] or something similar.

If I try to get this key, perhaps, rcmail return me an error. How can I retrive TEMPLOBJECT value?

Thanks in advance for your patience.
Title: Re: create html in on plugin and show it in Another
Post by: JohnDoh on December 16, 2019, 01:18:14 PM
it sounds like may be either a template_object_* hook or the template_container hook might be more useful. have a look here: https://github.com/roundcube/roundcubemail/wiki/Plugin-Hooks#template-hooks