php Visual Composer Prestashop插件

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php Visual Composer Prestashop插件相关的知识,希望对你有一定的参考价值。

<?php

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");
                               
  }

}

以上是关于php Visual Composer Prestashop插件的主要内容,如果未能解决你的问题,请参考以下文章

php Visual Composer - thêm控件

php Visual Composer - 删除我们不使用的VC元素

php 联系Form 7 w / Visual Composer Grid

php 联系Form 7 w / Visual Composer Grid

将 PHP 代码插入 Visual Composer

在页面上呈现Visual Composer短代码