Jump to content
ClicShopping News Read more... ×
Sign in to follow this  
ClicShopping

How to create an app and module can be downloaded from github

Recommended Posts

This tuto help you how to create a module to be downloaded from GitHub community or official add on.

 

Note : Currently, just the official add on can be downloaded in the admin.

 

In the future, it will be integrated (maybe) inside the application to allow the community to push their module on GitHub ClicShopping community.

 

In this tuto, we create a new module called: module_header_tags_favicon

 

Note : In different apps, you can also create a header tag module: For example like products app to include a header tag facebook. If you module header tag is used in all the website, it's better to follow this example.

 

Very important All the modules start must begin by :  module_

module_apps_best_selling, module_header_tags_touch_icon, modules_header_bootstrap_caroussel

 

 

The structure of the directory

 

module_header_tags_favicon  ===> note :  the directory must have the same name of your module
 

readme.md
LICENCSE
-- includes
----modules
----header_tags
-- ModulesInfosJson
-- sources
---- images
------ icons
---- languages
------ english
-------- modules
----------header_tags
------ french
-------- modules
----------header_tags

 

Step 1 Insides this directory : header_tags create a file called ht_favicon.php

-- includes
----modules
----header_tags

----- ht_favicon.php

 

insert this code

 

<?php
/**
 * he_favicon.php 
 * @copyright Copyright 2008 - http://www.innov-concept.com
 * @copyright Portions Copyright osCommerce
 * @license GNU Public License V2.0
 * @version $Id: 1.0
*/

  use ClicShopping\OM\Registry;
  use ClicShopping\OM\HTTP;
  use ClicShopping\OM\CLICSHOPPING;

  class ht_favicon {
    public $code;
    public $group;
    public $title;
    public $description;
    public $sort_order;
    public $enabled = false;

    public function __construct() {
      $this->code = get_class($this);
      $this->group = basename(__DIR__);

      $this->title = CLICSHOPPING::getDef('module_header_tags_favicon_title');
      $this->description = CLICSHOPPING::getDef('module_header_tags_favicon_description');

      if ( defined('MODULE_HEADER_TAGS_FAVICON_STATUS') ) {
        $this->sort_order = MODULE_HEADER_TAGS_FAVICON_SORT_ORDER;
        $this->enabled = (MODULE_HEADER_TAGS_FAVICON_STATUS == 'True');
      }
    }

    public function execute() {

      $OSCOM_Template = Registry::get('Template');

      $extansion_favicon = MODULE_HEADER_TAGS_FAVICON_EXTENSION_FAVICON;
      $OSCOM_Template->addBlock('<link rel="icon" type="image/'.$extansion_favicon.'" href="'. HTTP::getShopUrlDomain() . 'sources/images/icons/favicon.' . $extansion_favicon .'">', $this->group);
    }

    public function isEnabled() {
      return $this->enabled;
    }

    public function check() {
      return defined('MODULE_HEADER_TAGS_FAVICON_STATUS');
    }

    public function install() {
      $CLICSHOPPING_Db = Registry::get('Db');

      $CLICSHOPPING_Db->save('configuration', [
          'configuration_title' => 'Do you want install this module ?',
          'configuration_key' => 'MODULE_HEADER_TAGS_FAVICON_STATUS',
          'configuration_value' => 'True',
          'configuration_description' => 'Do you want activate this module ?',
          'configuration_group_id' => '6',
          'sort_order' => '1',
          'set_function' => 'osc_cfg_set_boolean_value(array(\'True\', \'False\'))',
          'date_added' => 'now()'
        ]
      );

      $CLICSHOPPING_Db->save('configuration', [
          'configuration_title' => 'Choose favicon extansion ?',
          'configuration_key' => 'MODULE_HEADER_TAGS_FAVICON_EXTENSION_FAVICON',
          'configuration_value' => 'png',
          'configuration_description' => 'Extansion allowed : png, gif ou ico : <br /><br /><strong>Note :</strong><br /><br />- The favicon must be in the  sources/image/icons directory',
          'configuration_group_id' => '6',
          'sort_order' => '1',
          'set_function' => 'osc_cfg_set_boolean_value(array(\'png\', \'gif\', \'ico\'))',
          'date_added' => 'now()'
        ]
      );

      $CLICSHOPPING_Db->save('configuration', [
          'configuration_title' => 'Display sort order',
          'configuration_key' => 'MODULE_HEADER_TAGS_FAVICON_SORT_ORDER',
          'configuration_value' => '75',
          'configuration_description' => 'Display sort order (lower is displayed in first)',
          'configuration_group_id' => '6',
          'sort_order' => '55',
          'set_function' => '',
          'date_added' => 'now()'
        ]
      );
      

      return $CLICSHOPPING_Db->save('configuration', ['configuration_value' => '1'],
                                               ['configuration_key' => 'WEBSITE_MODULE_INSTALLED']
                            );
    }

    public function remove() {
      return Registry::get('Db')->exec('delete from :table_configuration where configuration_key in ("' . implode('", "', $this->keys()) . '")');
    }

    public function keys() {
      return array('MODULE_HEADER_TAGS_FAVICON_STATUS',
                   'MODULE_HEADER_TAGS_FAVICON_EXTENSION_FAVICON',
                   'MODULE_HEADER_TAGS_FAVICON_SORT_ORDER');
    }
  }

 

Step 2 : In ModuleInfosJson directory, create module_header_tags_favicon.json

 

ModuleInfosJson

-- module_header_tags_favicon.json

 

Note : module_header_tags_favicon.json has the same namo of you root directory

 

the json must have these elements

 

{
  "title":			"module_header_tags_favicon",
  "type":       "meta tag",
  "vendor":			"header_tags",
  "is_free":   "Yes",
  "website_link_to_sell" : "",
  "version":			1.0,
  "req_core_version":	3.0,
  "license":			"GPL 2 - MIT",
  "tag":			    "header tag, script, meta tag, favicon",
  "install":            "includes/modules/",
  "module_directory":   "header_tags",
  "apps_name":          "",
  "type_module":        "fixe",
  "dependance":         "",

 "description":        "This module allow you to insert a favicon inside your site",
  "image":              "",

  "authors": [
    {
      "name":		    "ClicShopping Team",
      "company":	    "Innov-concept",
      "email":	        "",
      "website":	    "http://www.clicshopping.org",
      "Community":	  "http://www.clicshopping.org"
    }
  ]
}

Note on the most important json elements :

 

- title must have the same name of your directory

- type : apps or modules_directory (ex : modules_footer)
- is_free : Yes or No (if no include your link in website_link_to_sell)

- type module  : fixe or template

- dependance : if you must have another module to use this module. For example a hook

- module_directory:  Module directory (ex for apps module : ProductsListing)

- apps_name : Directory name of apps (ex : modules_apps_best_selling : BestSelling) else nothing

 

 

 

Step 3 : Image

In icons directory

-- sources
---- images
------ icons

 

In icons directory insert : favico.gif, favicon.ico, favicon.png

 

Step 4 Languages


 

---- languages
------ english
-------- modules
----------header_tags
------ french
-------- modules
----------header_tags

 

In each header_tags directory insert this file :  ht_favicon.txt and include inside

for english :
 

module_header_tags_favicon_title = Do you want use Favicon balise
module_header_tags_favicon_description = Add favicon balise in the store

 

for french :

 

module_header_tags_favicon_title = Souhaitez utiliser la balise Favicon pour afficher une petite image à cotè de l'URL ?
module_header_tags_favicon_description = Ajouter une petite image en 64x64 à coté de l'URL

 

Create a zip and send us the element for verification. it will be included in Github Community

 

Share this post


Link to post
Share on other sites
Sign in to follow this  

×

Important Information

By using this site, you agree to our Terms of Use