Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

call to undefinded method rcmail_output_json::button() #100

Closed
Offerel opened this issue Jan 11, 2018 · 1 comment
Closed

call to undefinded method rcmail_output_json::button() #100

Offerel opened this issue Jan 11, 2018 · 1 comment

Comments

@Offerel
Copy link

Offerel commented Jan 11, 2018

Im a little bit confused. I have now tried the following code in my client.js file:

var menu = rcm_callbackmenu_init({menu_name: 'mynewmenu', menu_source: '#menulist'});
$(buttonid).on("contextmenu", function(e) { rcm_show_menu(e, this, buttonid, mynewmenu); });

buttonid is the id of my button in the taskbar. In my plugin.php file i have a function for adding the menu above the page footer:

public function plugin_submenu()
    {
		$rcmail  = rcmail::get_instance();
			
		$li = '';
		$li .= html::tag('li', null, $rcmail->output->button(array('command' => 'plugin.myplugin.command1', 'type' => 'link', 'class' => 'myclass1', 'label' => 'myplugin.command1')));
		$li .= html::tag('li', null, $rcmail->output->button(array('command' => 'plugin.myplugin.command2', 'type' => 'link', 'class' => 'myclass2', 'label' => 'myplugin.command2')));
		$li .= html::tag('li', null, $rcmail->output->button(array('command' => 'plugin.myplugin.command3', 'type' => 'link', 'class' => 'myclass3', 'label' => 'myplugin.command3')));
		$out = html::tag('ul', array('id' => 'mymenu'), $li);
		$rcmail->output->add_footer(html::div(array('style' => 'display: none;'), $out));
    }

i call the public funnction in the last line of my plugin init with: $this->plugin_submenu();

but i get a error in the roundcube logfile:
PHP Fatal error: call to undefinded method rcmail_output_json::button()

Do you have any idea what i miss or can you please give a little bit more detailed instructions how to implement a submenu to a taskbar button?

Update: I have now seen that the div is added in the html source above the footer and in the header section rcmail.register_button is added for every entry in the menu. However, the php error is not gone :-( I didn't understand why the error occurs and the code is executed.

@Offerel
Copy link
Author

Offerel commented Jan 11, 2018

Oh my god. I didn't know why, but after changing the init part to

if (!$rcmail->action) {
            $this->plugin_submenu();
        }

instead of only $this->plugin_submenu();, it works Sorry for opening the issue.

@Offerel Offerel closed this as completed Jan 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant