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]
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.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.