V4.2.x what i miss in create module

Discussion in 'Modules / Plugins / Modifications' started by Abdulaziz, Aug 10, 2011.

  1. Abdulaziz Customer

    hi

    i tried to create module but i fail i follow the instructure in doc how to create module but i didn't know what i miss

    here what i do
    in config.php
    PHP:


    $data
    ['module']['name'] = "review";
    $data['module']['displayname'] = "Listing Review";
    $data['module']['description'] = "Allows members to write review on listing.";
    $data['module']['version'] = "v1";
    $data['module']['admin_capable'] = "1";
    $data['module']['user_capable'] = "0";



    init.php

    PHP:



    function install() {
        global 
    $db$class_tpl;
        
    $sSQL "DROP TABLE IF EXISTS " PREFIX "review";
        
    $db->query($sSQL);
        
    $sSQL "CREATE TABLE  " PREFIX "review (
    `reid` INT( 255 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
    `lid` INT( 255 ) NOT NULL ,
    `uid` INT( 255 ) NOT NULL ,
    `username` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
    `review` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL
    ) ENGINE = MYISAM ;"
    ;
        
    $db->query($sSQL);
        
    $class_tpl->assign('msg''Everything installed successfully.');
    }
    function 
    uninstall()
    {
        
        global 
    $db$class_tpl;
        
    $sSQL="DROP TABLE IF EXISTS ".PREFIX."review";
        
    $db->query($sSQL);
        if ( 
    $db->isError() )
        {
            
    $class_tpl->assign('msg''ERROR dropping the database.');
        }
        else
        {
            
    $class_tpl->assign('msg''Everything removed successfully.');
        }
    }

    in hooks.php
    PHP:



    class review {

        function 
    review(&$modules) {
            global 
    $db$class_tpl$modules;

            
    $modules->register('showReviewInHome'$this'showReview');
        }

        function 
    showReview() {
            echo 
    "hello world";
        }

    }

    so when i tried to put {modulehook function="showReviewInHome" options=""}
    it didnot work


    so any idea or some help to know what i miss

    thank in advance
  2. Mike-N-Tosh Developer & Moderator

    Did you activate the module in the admin?
  3. John Snyder Staff

    Try adding "_events" to then end of your class name and constructor as well.
  4. Mike-N-Tosh Developer & Moderator

    Holy cow! How the heck did I miss that when I looked at that post?

    That's why YOUR DA MAN, John!
  5. Abdulaziz Customer

    thanks a lot

    i don't know how it passed over me

    i am working on reviewing the module of listing which would allow the members to write their reviews on it.

    and i would be proud to share the module here.
  6. John Snyder Staff

    If you don't plan on selling it, you should create a github account and put it there, this way people can contribute to it and you can link directly to your source.

Share This Page