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

Test Module Won’t Install

Development and Programming

Ian Cook's avatar
Ian Cook
93 posts
16 years ago
Ian Cook's avatar Ian Cook

I’m starting to learn about module development, but my very basic module will not install.

I see the module in the modules list. When I click ‘install’, I get an entry in exp_modules for the module, but when I’m redirected back to the Addons page, the module is not indicated that it is installed. ie, no color highlight, the link still says ‘install’.

Here are the files I’m using, most of which came from the docs:

upd.ppl.php

<?php
class Ppl_upd { 

    var $version = '1.0'; 
     
    function Ppl_upd() 
    { 
        $this->EE =& get_instance();
        $this->EE->load->dbforge();
    }
    
    function install() 
    {

        $data = array(
            'module_name' => 'Power Page Locator' ,
            'module_version' => $this->version,
            'has_cp_backend' => 'n',
            'has_publish_fields' => 'n'
        );

        $this->EE->db->insert('modules', $data);
        
        return TRUE;
    }
    
    function uninstall()
    {
        $this->EE->db->select('module_id');
        $query = $this->EE->db->get_where('modules', array('module_name' => 'Power Page Locator'));

        $this->EE->db->where('module_id', $query->row('module_id'));
        $this->EE->db->delete('module_member_groups');

        $this->EE->db->where('module_name', 'Power Page Locator');
        $this->EE->db->delete('modules');

        return TRUE;
    }

    function update($current = '')
    {
        return false;
    }
}
?>

mcp.ppl.php

<?php
class Ppl_mcp {

    function Ppl_mcp()
    {
        $this->EE =& get_instance();
    }
}
?>

mod.ppl.php

<?php

class Ppl_mod { 

    var $return_data = ''; 
     
    function Ppl_mod() 
    { 
        $this->EE =& get_instance();
    }
    
    function test()
    {
        $this->return_data = 'Test successful';
    }
    
}
?>

./language/english/lang.ppl.php

<?php
$lang = array(

    'ppl_module_name'        => 'Power Page Locator',
    'ppl_module_description'    => 'PPL Tool',
    //----------------------------------------
    ''=>''
);

?>

I’ve done test installs on other third party modules and they work fine. I must be missing something very basic?

[Mod Edit: Moved to the Modules forum]

       
Ian Cook's avatar
Ian Cook
93 posts
16 years ago
Ian Cook's avatar Ian Cook

Note that this is EE 2 specific.

       
Gwarrior's avatar
Gwarrior
40 posts
16 years ago
Gwarrior's avatar Gwarrior

Are you getting any errors in the backend?

       
Ian Cook's avatar
Ian Cook
93 posts
16 years ago
Ian Cook's avatar Ian Cook

There are no errors. When I attempt to use the module, I get this:

Error The following tag cannot be processed: {exp:ppl:test} Please check that the ‘ppl’ module is installed and that ‘test’ is an available method of the module
       
Gwarrior's avatar
Gwarrior
40 posts
16 years ago
Gwarrior's avatar Gwarrior

Actually, now that I look at it, you’re not using DBForge to make the table.

Try this:

function install()
  {

      $data = array(
          'module_name' => 'Power Page Locator' ,
          'module_version' => $this->version,
          'has_cp_backend' => 'n',
          'has_publish_fields' => 'n'
       );

       $this->EE->db->insert('modules', $data);

       $fields = array(
        'ppl_id'    => array('type' => 'int', 'constraint' => '10', 'unsigned' => TRUE, 'auto_increment' => TRUE),
        'example_field'    => array('type' => 'varchar', 'constraint' => '70'),
        'example_field'    => array('type' => 'varchar', 'constraint' => '70'),
        'member_access'    => array('type' => 'varchar', 'constraint' => '250', 'default' => 'all')
        );

       $this->EE->load->dbforge();
       $this->EE->dbforge->add_field($fields);
       $this->EE->dbforge->add_key('ppl_id', TRUE);
       $this->EE->dbforge->create_table('ppls'); 
        
       return TRUE;


    }

Or whatever your needs are. That should work.

       
Ian Cook's avatar
Ian Cook
93 posts
16 years ago
Ian Cook's avatar Ian Cook

if my module doesnt use any db tables, why would i need to make one?

       
Ian Cook's avatar
Ian Cook
93 posts
16 years ago
Ian Cook's avatar Ian Cook

Is there a set of demonstration files that implement a ‘blank’ module?

       
Ian Cook's avatar
Ian Cook
93 posts
16 years ago
Ian Cook's avatar Ian Cook

bump .. anyone have any idea why this module won’t install?

       
Ian Cook's avatar
Ian Cook
93 posts
16 years ago
Ian Cook's avatar Ian Cook

Ok, found the problem:

'module_name' => 'Power Page Locator' ,

This line needs to match the module class name. This is not supposed to be the ‘module title’, as I thought. So this should be:

'module_name' => 'Ppl' ,

Thanks to Bjorn for posting some code I could take apart.

       

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.