4

I am new to EE development and am trying to get my head round creating a module. I've read various tutorials and docs and have a skeleton module created, but it will not install.

In the list of modules I can see the name and description of my module, but when I click "Install" nothing happens. The status is still "Not Installed".

I have checked the database and the modules table has an entry for my module, so the install() function is executing, but the status isn't changing.

Here is my upd file:

<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Photo_pdf_upd {

    public $version = '1.0';

    private $EE;

    /**
     * Class Constructor
     */
    public function __construct() {
        $this->EE =& get_instance();
    }

    // -------------------------------------

    /**
     * Installation Method
     *
     * Required by ExpressionEngine
     *
     * @return boolean  TRUE
     */
    public function install() {
        // Drop info on the module into the modules table
        $mod_data = array(
            'module_name'           => 'Photo PDF',
            'module_version'        => $this->version,
            'has_cp_backend'        => 'n',
            'has_publish_fields'    => 'n'
        );

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

        return TRUE;
    }

    // --------------------------------------

    /**
     * Module Uninstaller
     *
     * Required by ExpressionEngine
     *
     * @return boolean  TRUE
     */
    public function uninstall() {
        $mod = $this->EE->db->select('module_id')->get_where('modules', array('module_name'=>'Photo PDF'))->row('module_id');

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

        $this->EE->db->where('module_name', 'Photo PDF')->delete('modules');

        return TRUE;
    }

    // ---------------------------------------

    /**
     * Module Updater
     *
     * Required by ExpressionEngine
     *
     * @return boolean  TRUE
     */
    public function update($current = '') {
        // Nothing to do here
        return TRUE;
    }
}

/* End of File: upd.photo_pdf.php */

1 Answer 1

6

$mod_data['module_name'] should be class name of your actual module file (mod.photo_pdf.php), in your case 'Photo_pdf'

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.