Author Topic: How to change the content of html from plugin  (Read 1352 times)

Offline bakhtiyor

  • Jr. Member
  • **
  • Posts: 22
How to change the content of html from plugin
« on: November 02, 2011, 09:40:23 AM »
Well, I have created following plugin in order to show number of unread messages. It works fine, but the only problem it has is it doesn't update automatically when new mail arrives. What I want to do is to add a hook like: $this->add_hook('new_messages', array($this, 'notify')) and in the notify function to update the content of the object that I have in the template :. But I don't know how to do that, could you please help me in this problem?

Here is the code for my plugin:


class test extends rcube_plugin{
    public 
$task='mail';
    
    function 
init(){            
        
$this->register_handler('plugin.unreadmessage',array($this'unreadmessage_handler'));
        
$this->add_hook('new_messages', array($this'notify'));
    }
    
    function 
notify(){
        
// I need to write here the code in order to update the object which is in the template
       //  Need help please contribute in this work.
    
}
    
    function 
unreadmessage_handler(){
        
$rcmail rcmail::get_instance();        
        
$count=$rcmail->imap->messagecount('INBOX''UNSEEN');
	

        return 
"You have $count new messages";
    }
}


Thank you

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,585
    • http://SKaero.com/
How to change the content of html from plugin
« Reply #1 on: November 02, 2011, 11:40:26 PM »
You'll need to have a javascript file with a callback so the JS can update the count, for example: Doc_Plugins