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
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.
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);
}
// ENDThe 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.
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.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.