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

Troubleshooting a new homegrown extension

Development and Programming

PhilipR's avatar
PhilipR
21 posts
17 years ago
PhilipR's avatar PhilipR

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]

       
Derek Jones's avatar
Derek Jones
7,561 posts
17 years ago
Derek Jones's avatar Derek Jones

Your class and your filename do not match up, Philip. See the naming conventions in the Extension Development guide.

       
PhilipR's avatar
PhilipR
21 posts
17 years ago
PhilipR's avatar PhilipR

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!

       
Derek Jones's avatar
Derek Jones
7,561 posts
17 years ago
Derek Jones's avatar Derek Jones

Did you also change the class name here?

'class'        => "BulldogsRegistration",
       
PhilipR's avatar
PhilipR
21 posts
17 years ago
PhilipR's avatar PhilipR

Ack, no. Good catch. I should have used find-and-replace instead of just changing the class declaration and the c’tor. 😊

Thanks again.

       

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.