Extensions and Widgets Creation: Difference between revisions

From osCommerce Wiki
Jump to navigation Jump to search
(Created page with "'''Basic Provisions:''' # 1. All extensions must be placed in separate folder. # 2. The class file name must be the same as the folder name. # 3. Templates must be placed in f...")
 
No edit summary
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
'''Note: This manual is for osCommerce v4.'''
'''Basic Provisions:'''
'''Basic Provisions:'''
# 1. All extensions must be placed in separate folder.
# All extensions must be placed in separate folder.
# 2. The class file name must be the same as the folder name.
# The class file name must be the same as the folder name.
# 3. Templates must be placed in folder 'views'.
# Templates must be placed in folder 'views'.


//additional
//additional
if you want to use widgets in extensions
if you want to use widgets in extensions
1. Add method getWidgets with $type parameter and describe widgets in array
1. Add method getWidgets with $type parameter and describe widgets in array
example:
example:
return [
return [
            [
 
                'name' => 'CustomerLoyalty\ShoppingCart', 'title' => 'Customer Loyalty Info Box', 'description' => '', 'type' => 'cart',
            [
            ],
 
        ];
                'name' => 'CustomerLoyalty\ShoppingCart', 'title' => 'Customer Loyalty Info Box', 'description' => <nowiki>''</nowiki>, 'type' => 'cart',
 
            ],
 
        ];
 
in this case ShoppingCart (in subfolder \ShoppingCart) is widget ( ShoppingCart.php) can be used in customizing Themes
in this case ShoppingCart (in subfolder \ShoppingCart) is widget ( ShoppingCart.php) can be used in customizing Themes
2. to show additional settings for widget use method showSettings
2. to show additional settings for widget use method showSettings
example:
example:
    public static function showSettings($settings){
 
        return self::begin()->render('settings.tpl', ['settings' => $settings]);
    public static function showSettings($settings){
    }
 
        return self::begin()->render('settings.tpl', ['settings' => $settings]);
 
    }
 
extension installer:
extension installer:
1) extends \common\classes\modules\ModuleExtensions
1) extends \common\classes\modules\ModuleExtensions
2) install (example)
2) install (example)
    public function install($platform_id){
 
        parent::install($platform_id);// install in liek other modules
    public function install($platform_id){
        // install extention envirenment
 
        $migration = new \common\classes\Migration;
        parent::install($platform_id);// install in liek other modules
        $migration->addTranslation(['admin/main'], [
 
            //add keys
        // install extention envirenment
        ]);
 
        return;
        $migration = new \common\classes\Migration;
    }
 
        $migration->addTranslation(['admin/main'], [
 
            //add keys
 
        ]);
 
        return;
 
    }
 
2) ckeck extension enabled - use \common\helpers\Acl::checkExtensionAllowed($extName, 'allowed')
2) ckeck extension enabled - use \common\helpers\Acl::checkExtensionAllowed($extName, 'allowed')
    public static function allowed() {
 
        return self::enabled();
    public static function allowed() {
    }
 
        return self::enabled();
 
    }

Revision as of 10:35, 17 November 2021

Note: This manual is for osCommerce v4.

Basic Provisions:

  1. All extensions must be placed in separate folder.
  2. The class file name must be the same as the folder name.
  3. Templates must be placed in folder 'views'.

//additional

if you want to use widgets in extensions

1. Add method getWidgets with $type parameter and describe widgets in array

example:

return [

            [

                'name' => 'CustomerLoyalty\ShoppingCart', 'title' => 'Customer Loyalty Info Box', 'description' => '', 'type' => 'cart',

            ],

        ];

in this case ShoppingCart (in subfolder \ShoppingCart) is widget ( ShoppingCart.php) can be used in customizing Themes

2. to show additional settings for widget use method showSettings

example:

    public static function showSettings($settings){

        return self::begin()->render('settings.tpl', ['settings' => $settings]);

    }

extension installer:

1) extends \common\classes\modules\ModuleExtensions

2) install (example)

    public function install($platform_id){

        parent::install($platform_id);// install in liek other modules

        // install extention envirenment

        $migration = new \common\classes\Migration;

        $migration->addTranslation(['admin/main'], [

            //add keys

        ]);

        return;

    }

2) ckeck extension enabled - use \common\helpers\Acl::checkExtensionAllowed($extName, 'allowed')

    public static function allowed() {

        return self::enabled();

    }