We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Extension Hook not calling Method

Development and Programming

Adam Christianson's avatar
Adam Christianson
115 posts
14 years ago
Adam Christianson's avatar Adam Christianson

I’m pretty new to Expression Engine development and I thought I understood the Extension Developer docs, but I’ve hit a wall with an existing extension that was built for 1.6.9 by another developer that I’m trying to convert to 2.1.3. I have successfully updated the syntax and I can see it in the add-ons in EE admin, but then it gets weird.

I can click the ‘Enable’ link and it does call the activate method and insert the extension and settings and in the ‘exp_extensions table. It also sets enabled to ‘y’ as expected. In the admin though the ‘Settings’ link doesn’t become active and the ‘Disabled’ text still appears. I can manipulate the URL to get to the settings for the extension and I can even save and persist settings changes, but still the Add-on console shows the extension and not enabled. Clicking ‘Disable’ successfully toggles and removes the extension.

The other thing is that while the extension is in the sudo “enabled” state it doesn’t appear to call the the method I have attached to the extension hook. In this case I’m using the ‘edit_template_end’ hook. I’m sure there is some noob think I’m missing here, so I’m open to any thoughts.

Thanks

       
Adam Christianson's avatar
Adam Christianson
115 posts
14 years ago
Adam Christianson's avatar Adam Christianson

Does anyone have even any advice on how to best troubleshoot something like this? Is there a way to verify if the method called by a hook is even getting fired? I tried just adding a dump to the start of the function that should be called by my hook and I don’t get anything in the admin interface, so I assume it’s not being called.

       
Focus Lab Dev Team's avatar
Focus Lab Dev Team
1,129 posts
14 years ago
Focus Lab Dev Team's avatar Focus Lab Dev Team

Hey Adam,

It sounds like you may have not used the correct naming convention when storing data in the db. EE loads the Extensions page checking the db against add-ons with a very specific approach.

Can you share the activate method code here?

       
Adam Christianson's avatar
Adam Christianson
115 posts
14 years ago
Adam Christianson's avatar Adam Christianson

Thanks for responding. Here is the activate code I’m using.

// --------------------------------
    //  Activate Extension
    // --------------------------------
    
    function activate_extension()
    {
        
        $this->settings = array(
            'webpage_dir'        => '/var/www/web_dir/',
            'css_dir'            => '../styles/',
            'js_dir'            => '../js/',
            'rss_dir'            => '../rss/',
            'webpage_templates'    => array('ms',$this->_template_list(),''),
            'css_templates'        => array('ms',$this->_template_list('css'),''),
            'js_templates'        => array('ms',$this->_template_list('js'),''),
            'rss_templates'        => array('ms',$this->_template_list('rss'),'')
        );
        
        $data = array(
                'class'        => __CLASS__,
                'method'    => 'edit_template_end',
                'hook'        => 'edit_template_end',
                'settings'    => serialize($this->settings),
                'priority'    => 10,
                'version'    => $this->version,
                'enabled'    => 'y'
            );

        $this->EE->db->insert('extensions', $data);
    }
    // END

The funny thing is that after I run the activate in the admin the exp_extension table does get updated and this extension is added along with the settings data.

       
Focus Lab Dev Team's avatar
Focus Lab Dev Team
1,129 posts
14 years ago
Focus Lab Dev Team's avatar Focus Lab Dev Team

Adam,

I’m not sure that the edit_template_end hook exists in 2.x any longer. I did a search in the core files for it and didn’t see it anywhere.

Perhaps that’s the core of the issue.

       
Adam Christianson's avatar
Adam Christianson
115 posts
14 years ago
Adam Christianson's avatar Adam Christianson

Ahh, you’re right. Looks like they may have renamed that hook to ‘update_template_end’?

http://ellislab.com/expressionengine/user-guide/development/extension_hooks/cp/design/index.html#update_template_end

Funny that they re-named that, but kept the other one of the ‘Design’ hooks, ‘edit_template_start’, the same.

That could explain a lot. I don’t get why they do that. Also it would be nice if the would provide a single page list of all the available extension hooks, like they did here for 1.X, http://expressionengine.com/developers/extension_hooks/ would make it a lot easier to find changes like this.

       
Focus Lab Dev Team's avatar
Focus Lab Dev Team
1,129 posts
14 years ago
Focus Lab Dev Team's avatar Focus Lab Dev Team

Strange. It would be nice to have that referenced somewhere like here as well: http://ellislab.com/expressionengine/user-guide/development/conversion/syntax.html

Does changing the name of the hook solve some of the issues you had?

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.