Snippets

SmartDatasoft vcsimpleaddons

Created by Arifur Rahman
<?php
/*
* 2007-2014 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author PrestaShop SA <contact@prestashop.com>
*  @copyright  2007-2014 PrestaShop SA

*  @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*/

if (!defined('_CAN_LOAD_FILES_'))
	exit;
	
	class VcSimpleAddons extends Module
{
	public function __construct()
	{
		$this->name = 'vcsimpleaddons';
		$this->author = 'SmartDataSoft';
		$this->tab = 'front_office_features';
		
		$this->version = '1.1.1';

		$this->bootstrap = true;
		parent::__construct();	


       	JsComposer::add_shortcode('bartag',array(&$this,'renderMyBartag'));


		$this->displayName = $this->l('Visual Composer Simple Addons');
		$this->description = $this->l('This is a simple visual composer addons');
		$this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_);
	}
	
	public function install()
	{
		return (parent::install() && $this->registerHook('vcBeforeInit'));
	}
	public function hookvcBeforeInit() {


       $vc = vc_manager();
 
			 /*
        Add your Visual Composer logic here.
        Lets call vc_map function to "register" our custom shortcode within Visual Composer interface.

        More info: http://kb.wpbakery.com/index.php?title=Vc_map
        */
        if(function_exists("vc_map")){

        vc_map( array(
            "name" => $vc->l("My Bar Shortcode"),
            "description" => $vc->l("Bar tag description text"),
            "base" => "bartag",
            "class" => "",
            "controls" => "full",
           // "icon" => plugins_url('assets/asterisk_yellow.png', __FILE__), // or css class name which you can reffer in your css file later. Example: "vc_extend_my_class"
            "category" => $vc->l('Content'),
            //'admin_enqueue_js' => array(plugins_url('assets/vc_extend.js', __FILE__)), // This will load js file in the VC backend editor
            //'admin_enqueue_css' => array(plugins_url('assets/vc_extend_admin.css', __FILE__)), // This will load css file in the VC backend editor
            "params" => array(
                array(
                  "type" => "textfield",
                  "holder" => "div",
                  "class" => "",
                  "heading" => $vc->l("Text"),
                  "param_name" => "foo",
                  "value" => $vc->l("Default params value"),
                  "description" => $vc->l("Description for foo param.")
              ),
              array(
                  "type" => "colorpicker",
                  "holder" => "div",
                  "class" => "",
                  "heading" => $vc->l("Text color"),
                  "param_name" => "color",
                  "value" => '#FF0000', //Default Red color
                  "description" => $vc->l("Choose text color")
              ),
              array(
                  "type" => "textarea_html",
                  "holder" => "div",
                  "class" => "",
                  "heading" => $vc->l("Content"),
                  "param_name" => "content",
                  "value" => $vc->l("<p>I am test text block. Click edit button to change this text.</p>"),
                  "description" => $vc->l("Enter your content.")
              ),
 
            )
        ) );
    }


}
     /*
    Shortcode logic how it should be rendered
    */
    public function renderMyBartag( $atts, $content = null ) {
      extract( 	JsComposer::shortcode_atts( array(
        'foo' => 'something',
        'color' => '#FF0000'
      ), $atts ) );
    
     $this->loadCssAndJs();

      $output = "<div style='color:{$color};' data-foo='${foo}'>{$content}</div>";
      return $output;
    }
     /*
    Load plugin css and javascript files which you may need on front end of your site
    */
    public function loadCssAndJs() {
    
     $url = __PS_BASE_URI__ . 'modules/vcsimpleaddons/';
 
 
    $this->context->controller->addCSS("{$url}css/vc_extend.css");
    $this->context->controller->addJS("{$url}js/vc_extend.js");
                               
  }

}

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.