I’ve tried installing it, yet that doesn’t work. It does add it to the esp_modules and add the tables I told it to, yet then it doesn’t say it’s installed and it apears that only the install function ran, here’s the code for the uploader :
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Upload_pictures_upd
{
var $version='1.0';
function Upload_pictures_upd()
{
$this->EE=& get_instance();
}
function tabs()
{
$tabs['upload pictures']=array(
'upload_pictures_ids'=>array(
'visible' =>true,
'collapse' =>false,
'htmlbuttons' =>false,
'width' =>'100%'
)
);
return $tabs;
}
function install()
{
$this->EE->load->dbforge();
$data=array(
'module_name' =>'Picture uploader',
'module_version' =>$this->version,
'has_cp_backend' =>'y',
'has_publish_fields'=>'y'
);
$this->EE->db->insert('modules',$data);
$this->EE->load->library('layout');
$this->EE->layout->add_layout_tabs($this->tabs(),'Upload_pictures');
$fields = array(
'id' => array('type' => 'int', 'constraint' => '10', 'unsigned' => TRUE, 'auto_increment' => TRUE),
'name' => array('type' => 'varchar', 'constraint' => '250'),
);
$this->EE->dbforge->add_field($fields);
$this->EE->dbforge->add_key('id', TRUE);
$this->EE->dbforge->create_table('albums');
unset($fields);
$fields = array(
'id' =>array('type' => 'int', 'constraint' => '10', 'unsigned' => TRUE, 'auto_increment' => TRUE),
'caption' =>array('type' => 'varchar', 'constraint' => '250'),
'album' =>array('type' => 'int','constraint'=>'10'),
'thumbl' =>array('type' => 'LONGBLOB'),
'filename'=>array('type' => 'LONGBLOB')
);
$this->EE->dbforge->add_field($fields);
$this->EE->dbforge->add_key('id', TRUE);
$this->EE->dbforge->create_table('photos');
return true;
}
function uninstall()
{
$this->EE->load->library("layout");
$this->EE->db->query("DROP TABLE `exp_albums`");
$this->EE->db->query("DROP TABLE `exp_photos`");
$this->EE->db->query("DELETE FROM exp_modules WHERE module_name='Picture uploader'");
$this->EE->layout->delete_layout_tabs($this->tabs(),'Upload_pictures');
return true;
}
function update($current='')
{
return false;
}
}ok, I tried that yet it still does the same thing? Is there any other possible error, maybe in another script? Also I updated the code with what it is now. Also, thanks for the help.
Out of curiosity, does the following code work?
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Upload_pictures_upd
{
var $version='1.0';
function Upload_pictures_upd()
{
$this->EE=& get_instance();
}
function tabs()
{
$tabs['upload pictures']=array(
'upload_pictures_ids'=>array(
'visible' =>true,
'collapse' =>false,
'htmlbuttons' =>false,
'width' =>'100%'
)
);
return $tabs;
}
function install()
{
$this->EE->load->dbforge();
$data=array(
'module_name' =>__CLASS__,
'module_version' =>$this->version,
'has_cp_backend' =>'y',
'has_publish_fields'=>'y'
);
$this->EE->db->insert('modules',$data);
$this->EE->load->library('layout');
$this->EE->layout->add_layout_tabs($this->tabs(),__CLASS__);
$fields = array(
'id' => array('type' => 'int', 'constraint' => '10', 'unsigned' => TRUE, 'auto_increment' => TRUE),
'name' => array('type' => 'varchar', 'constraint' => '250'),
);
$this->EE->dbforge->add_field($fields);
$this->EE->dbforge->add_key('id', TRUE);
$this->EE->dbforge->create_table('albums');
unset($fields);
$fields = array(
'id' =>array('type' => 'int', 'constraint' => '10', 'unsigned' => TRUE, 'auto_increment' => TRUE),
'caption' =>array('type' => 'varchar', 'constraint' => '250'),
'album' =>array('type' => 'int','constraint'=>'10'),
'thumbl' =>array('type' => 'LONGBLOB'),
'filename'=>array('type' => 'LONGBLOB')
);
$this->EE->dbforge->add_field($fields);
$this->EE->dbforge->add_key('id', TRUE);
$this->EE->dbforge->create_table('photos');
return true;
}
function uninstall()
{
$this->EE->load->library("layout");
$this->EE->db->query("DROP TABLE `exp_albums`");
$this->EE->db->query("DROP TABLE `exp_photos`");
$this->EE->db->query("DELETE FROM exp_modules WHERE module_name='".__CLASS__."'");
$this->EE->layout->delete_layout_tabs($this->tabs(),__CLASS__);
return true;
}
function update($current='')
{
return false;
}
}What I usually do to debug is strip it down to its most basic form and add from there until it breaks. Then I know exactly where things go wrong.
Try this first and keep adding code back in until it breaks.
function install()
{
$data=array(
'module_name' =>__CLASS__,
'module_version' =>$this->version,
'has_cp_backend' =>'y',
'has_publish_fields'=>'y'
);
$this->EE->db->insert('modules', $data);
return TRUE;
}Also, as of EE 2.1.2 PHP4 support has ended, which means they’re using PHP5 constructors now (__construct). I usually add both for backwards compatibility:
function Upload_pictures_upd()
{
$this->__construct();
}
function __construct()
{
$this->EE=& get_instance();
}
// END __constructorWouter
Far as I know, there’s nothing forcing you to utilize JS to make a CP backend page. I believe you can submit any form you generate on the CP page to the action URL for your module, documented here.
Not to belabor this, but I think you’ll want to use the module’s “primary” class name–in this case “Upload_pictures”–instead of the update file’s class name (“Upload_pictures_upd”), which is what you’d get if you used CLASS.
So I think something like this would be more appropriate in the install() method:
$data=array(
'module_name' =>'Upload_pictures',
'module_version' =>$this->version,
'has_cp_backend' =>'y',
'has_publish_fields'=>'y'
);Guys, please speak up if I’m wrong.
Something else you may be interested in for debugging is Experience Internet’s OmniLog module. It looks promising.
…I think you’ll want to use the module’s “primary” class name–in this case “Upload_pictures”–instead of the update file’s class name (“Upload_pictures_upd”), which is what you’d get if you used __CLASS__.
Excellent point. I responded quickly thinking about Extensions, not modules. Pardon my error.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.