Author Topic: create html in on plugin and show it in Another  (Read 4343 times)

Offline sago

  • Newbie
  • *
  • Posts: 7
create html in on plugin and show it in Another
« 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
« Last Edit: December 15, 2019, 03:50:00 AM by sago »

Offline JohnDoh

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2,845
Re: create html in on plugin and show it in Another
« Reply #1 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.
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more…

Offline sago

  • Newbie
  • *
  • Posts: 7
Re: create html in on plugin and show it in Another
« Reply #2 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.

Offline JohnDoh

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2,845
Re: create html in on plugin and show it in Another
« Reply #3 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
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more…