Hostbill plugin development

6 Jun

Hostbill plugin development

1)Create a folder with plugin name.
If plugin name is example, create a folder with name ‘example’.

2)Create a file named
class.example.php. Also a folder named admin in it.

3)In the admin folder create a file named
class.example_controller.php
also can create tpl files here.

Let’s create a tpl named default.tpl here.

4)Let’s create client side basic code in the file class.example.php.


<?php

class example extends OtherModule {

protected $modname = 'Example';
protected $description = 'Sampple Plugin';
protected $version = '0.1';

protected $info = array(
        'haveadmin'    => true,  // is module accessible from adminarea
        'haveuser'     => false, // is module accessible from client area
        'havelang'     => false, // does module support multilanguage
        'havetpl'      => false, // does module have template
        'havecron'     => false, // does module support cron calls
        'haveapi'      => false, // is module accessible via api
        'needauth'     => false, // does module needs authorisation
        'isobserver'   => false, // is module an observer
        'clients_menu' => false, // listing in adminarea->clients menu
        'support_menu' => false, // listing in adminarea->support menu
        'payment_menu' => false, // listing in adminarea->payments menu
        'orders_menu'  => false, // listing in adminarea->orders menu
        'extras_menu'  => true, // listing in extras menu
        'mainpage'     => true, // listing in admin/client home
        'header_js'    => false, // does module have getHeaderJS function
    );

protected $configuration=array(
         'Field1' => array(
            'value' => '',
            'type' => 'input',
            'description' => 'My description'
        ),
        'Field2' => array(
            'value' => '',
            'type' => 'input',
            'description' => 'My description'
        ),
        'Field3' => array(
            'value' => '0',
            'type' => 'check',
            'description' => 'My description'
        )
    );

public function install() {
  echo "Install";
  return true;
}

}

5)

<?php


class example_controller extends HBController {
    /*
	?cmd=example
    */


    function _default($request) {
	//default function, just like our default index.php
        $showheaderandfooter = true;
        $module_type = 'Other';
        $this->template->assign('test', 'test');
        $this->template->render(
                APPDIR_MODULES .
                $module_type . '/example/admin/default.tpl', [], $showheaderandfooter
        );

    }

    /*
	?cmd=example&action=testfunction
    */

    function testfunction($param) {
	//action=testfunction, even for post action we can do like this
        $showheaderandfooter = true;
        $module_type = 'Other';
        $this->template->assign('test', 'test');
        $this->template->render(
                APPDIR_MODULES .
                $module_type . '/example/admin/testfunction.tpl', [], $showheaderandfooter
        );
    }


}

6)The content added to the file admin/default.tpl is
{$test}

Leave a Reply

Your email address will not be published. Required fields are marked *