I’m attempting to follow the docs and deploy a custom extension. I think I’ve done all the required steps, but in the Extensions Manager
I understand that ExpressionEngine 1.4.2 which we’re using is an old version, but I’d rather avoid going through a version upgrade with a deliverable due if I can avoid it. If that’s a prerequisite to get my extension to work then I’ll have to evaluate when I can upgrade.
Here’s the extension code, which of course is just a stub right now with all the sample methods pasted in, in the system/extensions/ext.bulldogs_registration.php directory:
<?php
class BulldogsRegistration
{
var $settings = array();
var $name = 'Bulldogs Extension';
var $version = '0.0.1';
var $description = 'Bulldogs.com additional registration tasks';
var $settings_exist = 'n';
var $docs_url = 'http://www.bulldogs.com';
// -------------------------------
// Constructor - Extensions use this for settings
// -------------------------------
function BulldogsRegistration($settings='')
{
$this->settings = $settings;
}
function activate_extension()
{
global $DB;
$DB->query($DB->insert_string('exp_extensions',
array(
'extension_id' => '',
'class' => "BulldogsRegistration",
'method' => "bulldogs_register_user",
'hook' => "member_member_register",
'settings' => "",
'priority' => 2,
'version' => $this->version,
'enabled' => "y"
)
)
);
}
function bulldogs_register_user ($data)
{
var_dump($data);
}
// --------------------------------
// Update Extension
// --------------------------------
function update_extension($current='')
{
global $DB;
if ($current == '' OR $current == $this->version)
{
return FALSE;
}
$DB->query("UPDATE exp_extensions
SET version = '".$DB->escape_str($this->version)."'
WHERE class = 'Example_extension'");
}
}
// END CLASS
?>
Yesterday when I pressed “Enable Extensions?”, and confirmed, nothing changed. I think this may have been because of permissions on my config.php. Today I’m able to toggle between enabled and disabled at will, but nothing ever shows up under the headings “Extension Name Documentation Settings Status”. How can I troubleshoot why my extension isn’t being found?
(This extension is in response to this requirement.)
[Mod edit: Moved to Extensions Troubleshooting forum]
Your class and your filename do not match up, Philip. See the naming conventions in the Extension Development guide.
Thanks, Derek. Changing the class name to Bulldogs_Registration made it appear. (Apparently it’s not case-sensitive.) I’m still having problems with enabling it; when I click the “Enable?” per-extension link, nothing changes. I’m thinking this may be another permissions issue.
Perhaps the documentation should use a different term than convention for naming requirements in extensions? I usually think of a naming convention as a policy helpful to the human users rather than a requirement for things to work correctly.
FWIW I’ve been working with CakePHP and before that Rails, and in both cases a camel-cased MyObject model class is considered to map to a my_object file name and a my_objects table – hence I forgot that other frameworks don’t use this mapping!
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.