Hi, I wrote up a simple module following the official EE2 module tutorial. After uploading, the modules page in Admins sees it and I click the install link. The subsequent page is the listing of modules again with a flash message at the top of the page saying “module installed successfully”. However, the listing says “Not Installed” in red. Indeed, templates calling this module via the {exp:} syntax return an error message saying the module is not installed.
I see no error messages and my server logs show nothing out of the ordinary. Below is my upd.cfa_bios.php. How can I find out what I did wrong in writing the module?
Thanks!
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
*
* @author mgatto
*
*/
class Cfa_bios_upd {
/**
*
* @var unknown_type
*/
var $version = '0.9.0';
var $name = 'CFA Staff and Faculty Biographies';
/**
*
* @return unknown_type
*/
function Cfa_bios_upd()
{
// Make a local reference to the ExpressionEngine super object
$this->EE =& get_instance();
}
/**
*
* @return unknown_type
*/
function install()
{
$errors = array();
try {
$this->EE->load->dbforge();
$data = array(
'module_name' => $this->name,
'module_version' => $this->version,
'has_cp_backend' => 'n',
'has_publish_fields' => 'n'
);
$this->EE->db->insert('modules', $data);
} catch (Exception $e) {
$errors[] = $e->getMessage();
}
if (count($errors) > 0) {
$this->install_errors = $errors;
return FALSE;
}
else {
return TRUE;
}
}
/**
*
* @return unknown_type
*/
function uninstall()
{
$this->EE->load->dbforge();
$this->EE->db->select('module_id');
$query = $this->EE->db->get_where('modules', array('module_name' => $this->name));
$this->EE->db->where('module_id', $query->row('module_id'));
$this->EE->db->delete('module_member_groups');
$this->EE->db->where('module_name', $this->name);
$this->EE->db->delete('modules');
$this->EE->db->where('class', $this->name);
$this->EE->db->delete('actions');
return TRUE;
}
/**
*
* @param $current
* @return unknown_type
*/
function update($current = '')
{
return FALSE;
}
}Hey, I just figured out what the issue is… You need to make sure you don’t have any spaces in the Module name in the modules $data array.
hmm.. would be nice if they stuck an error message in there. at least when some debug flag is on or something.
anyway that was my problem too - that module name should be the same name as the class in your mod. file, also same module_name in the upd. uninstall method or else it might not uninstall.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.