Random Prestashop模块选项卡滑块随机乘积
这是Prestashop CMS的标签类别滑块模块,它显示最后添加的产品,我需要显示随机产品 如果需要,我会添加更多信息 感谢我的英语不好 谢谢你们的帮助Random Prestashop模块选项卡滑块随机乘积,random,prestashop,Random,Prestashop,这是Prestashop CMS的标签类别滑块模块,它显示最后添加的产品,我需要显示随机产品 如果需要,我会添加更多信息 感谢我的英语不好 谢谢你们的帮助 class postabcateslider1 extends Module { private $spacer_size = '5'; private $_postErrors = array(); private $_html= null; public function __construct() {
class postabcateslider1 extends Module {
private $spacer_size = '5';
private $_postErrors = array();
private $_html= null;
public function __construct() {
$this->name = 'postabcateslider1';
$this->tab = 'front_office_features';
$this->version = '1.5';
$this->author = 'posthemes';
$this->displayName = $this->l('Category Tabs Slider 1');
$this->description = $this->l('Category Tabs Slider 1');
parent :: __construct();
}
public function install() {
Configuration::updateValue($this->name . '_p_on_row', 4);
Configuration::updateValue($this->name . '_p_limit', 30);
Configuration::updateValue($this->name . '_tab_effect', 'wiggle');
Configuration::updateValue($this->name . '_p_on_row', 4);
Configuration::updateValue($this->name . '_p_width', 150);
Configuration::updateValue($this->name . '_p_height', 200);
Configuration::updateValue($this->name . '_min_item', 1);
Configuration::updateValue($this->name . '_max_item', 5);
Configuration::updateValue($this->name . '_speed_slide', 3000);
Configuration::updateValue($this->name . '_a_speed', 500);
Configuration::updateValue($this->name . '_show_arrow', 0);
Configuration::updateValue($this->name . '_show_ctr', 0);
$arrayDefault = array('CAT3','CAT4','CAT5');
$cateDefault = implode(',',$arrayDefault);
Configuration::updateGlobalValue($this->name . '_list_cate',$cateDefault);
return parent :: install()
&& $this->registerHook('top')
/* && $this->registerHook('displayHome') */
&& $this->registerHook('blockPosition2')
//&& $this->registerHook('displayHome')
&& $this->registerHook('header')
&& $this->registerHook('actionOrderStatusPostUpdate')
&& $this->registerHook('addproduct')
&& $this->registerHook('updateproduct')
&& $this->registerHook('deleteproduct');
}
public function uninstall() {
Configuration::deleteByName($this->name . '_list_cate');
$this->_clearCache('postabcateslider1.tpl');
return parent::uninstall();
}
public function psversion() {
$version=_PS_VERSION_;
$exp=$explode=explode(".",$version);
return $exp[1];
}
public function hookHeader($params){
// if ($this->psversion()==5){
// $this->context->controller->addCSS(($this->_path).'postabcateslider.css', 'all');
// $this->context->controller->addCSS(($this->_path).'animate.delay.css', 'all');
// $this->context->controller->addCSS(($this->_path).'animate.min.css', 'all');
// } else {
// Tools::addCSS(($this->_path).'postabcateslider.css');
// Tools::addCSS(($this->_path).'animate.delay.css');
// Tools::addCSS(($this->_path).'animate.min.css');
// }
}
public function hookblockPosition2($params) {
$nb = Configuration::get($this->name . '_p_limit');
$product_on_row = Configuration::get($this->name . '_p_on_row');
$arrayCategory = array();
$catSelected = Configuration::get($this->name . '_list_cate');
$cateArray = explode(',', $catSelected);
$id_lang =(int) Context::getContext()->language->id;
$id_shop = (int) Context::getContext()->shop->id;
$arrayProductCate = array();
foreach($cateArray as $id_category) {
$id_category = str_replace('CAT','',$id_category);
$category = new Category((int) $id_category, (int) $id_lang, (int) $id_shop);
$categoryProducts = $category->getProducts($this->context->language->id, 0, ($nb ? $nb : 5),'date_add','DESC');
if($categoryProducts) {
$arrayProductCate[] = array('id' => $id_category, 'name'=> $category->name, 'product' => $categoryProducts);
}
}
$options = array(
'p_width' => Configuration::get($this->name . '_p_width'),
'p_height' => Configuration::get($this->name . '_p_height'),
'speed_slide' => Configuration::get($this->name . '_speed_slide'),
'a_speed' => Configuration::get($this->name . '_a_speed'),
'show_des' => Configuration::get($this->name . '_show_des'),
'show_arrow' => Configuration::get($this->name . '_show_arrow'),
'show_ctr' => Configuration::get($this->name . '_show_ctr'),
'min_item' => Configuration::get($this->name . '_min_item'),
'max_item' => Configuration::get($this->name . '_max_item'), 'show_price' => Configuration::get($this->name . '_show_price'),
);
$this->context->smarty->assign('slideOptions', $options);
$this->smarty->assign(array(
'productCates' => $arrayProductCate,
'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'),
'homeSize' => Image::getSize(ImageType::getFormatedName('home')),
'product_on_row' => $product_on_row,
'tab_effect' => Configuration::get($this->name . '_tab_effect'),
'title' => Configuration::get($this->name . '_title'),
));
return $this->display(__FILE__, 'postabcateslider1.tpl');
}
public function getContent() {
$output = '<h2>' . $this->displayName . '</h2>';
if (Tools::isSubmit('submitPosTabCate')) {
if (!sizeof($this->_postErrors))
$this->_postProcess();
else {
foreach ($this->_postErrors AS $err) {
$this->_html .= '<div class="alert error">' . $err . '</div>';
}
}
}
return $output . $this->_displayForm();
}
public function getSelectOptionsHtml($options = NULL, $name = NULL, $selected = NULL) {
$html = "";
$html .='<select name =' . $name . ' style="width:130px">';
if (count($options) > 0) {
foreach ($options as $key => $val) {
if (trim($key) == trim($selected)) {
$html .='<option value=' . $key . ' selected="selected">' . $val . '</option>';
} else {
$html .='<option value=' . $key . '>' . $val . '</option>';
}
}
}
$html .= '</select>';
return $html;
}
private function _postProcess() {
Configuration::updateValue($this->name . '_list_cate', implode(',', Tools::getValue('list_cate')));
Configuration::updateValue($this->name . '_p_on_row', Tools::getValue('p_on_row'));
Configuration::updateValue($this->name . '_p_limit', Tools::getValue('p_limit'));
Configuration::updateValue($this->name . '_tab_effect', Tools::getValue('tab_effect'));
Configuration::updateValue($this->name . '_title', Tools::getValue('title'));
Configuration::updateValue($this->name . '_p_height', Tools::getValue('p_height'));
Configuration::updateValue($this->name . '_p_width', Tools::getValue('p_width'));
Configuration::updateValue($this->name . '_p_limit', Tools::getValue('p_limit'));
Configuration::updateValue($this->name . '_speed_slide', Tools::getValue('speed_slide'));
Configuration::updateValue($this->name . '_a_speed', Tools::getValue('a_speed'));
Configuration::updateValue($this->name . '_show_arrow', Tools::getValue('show_arrow'));
Configuration::updateValue($this->name . '_show_ctr', Tools::getValue('show_ctr'));
Configuration::updateValue($this->name . '_min_item', Tools::getValue('min_item'));
Configuration::updateValue($this->name . '_max_item', Tools::getValue('max_item'));
$this->_html .= '<div class="conf confirm">' . $this->l('Settings updated') . '</div>';
}
private function _displayForm(){
$spacer = str_repeat(' ', $this->spacer_size);
$tabEffect = array();
$tabEffect = array(
'none' => 'None',
'hinge' => 'Hinge',
'flash' => 'Flash',
'shake' => 'Shake',
'bounce' => 'Bounce',
'tada' => 'Tada' ,
'swing' => 'Swing',
'wobble' => 'Wobble',
'pulse' => 'Pulse',
'flip' => 'Flip',
'flipInX' => 'FlipInX',
'flipInY' => 'FlipInY',
'fadeIn' => 'FadeIn',
'bounceInUp' => 'BounceInUp',
'fadeInLeft' => 'FadeInLeft',
'rollIn' => 'RollIn',
'lightSpeedIn' => 'LightSpeedIn',
'wiggle' => 'Wiggle',
'rotateIn' => 'RotateIn',
'rotateInUpLeft' => 'RotateInUpLeft',
'rotateInUpRight' => 'RotateInUpRight'
);
$this->_html .= '
<form action="'.$_SERVER['REQUEST_URI'].'" method="post">
<fieldset>
<legend><img src="../img/admin/cog.gif" alt="" class="middle" />' . $this->l('Settings') . '</legend>
<label>'.$this->l('Title: ').'</label>
<div class="margin-form">
<input type = "text" name="title" value ='.(Tools::getValue('title')?Tools::getValue('title'): Configuration::get($this->name.'_title')).' ></input>
</div>
<label>'.$this->l('Effect Tab: ').'</label>
<div class="margin-form">';
$this->_html .= $this->getSelectOptionsHtml($tabEffect,'tab_effect', (Tools::getValue('tab_effect') ? Tools::getValue('tab_effect') : Configuration::get($this->name . '_tab_effect')));
$this->_html .='
</div>';
$this->_html .= '<label>' . $this->l('Show Link/Label Category: ') . '</label>';
$this->_html .= '<div class="margin-form">';
$this->_html .= '<select multiple="multiple" name ="list_cate[]" style="width: 200px; height: 160px;">';
// BEGIN Categories
$id_lang = (int) Context::getContext()->language->id;
$this->getCategoryOption(1, (int) $id_lang, (int) Shop::getContextShopID());
$this->_html .= '</select>
</div>';
$this->_html .='
<label>' . $this->l('Show Next/Back control: : ') . '</label>
<div class="margin-form">';
$this->_html .= $this->getSelectOptionsHtml(array(0 => 'No', 1 => 'Yes'), 'show_arrow', (Tools::getValue('title') ? Tools::getValue('show_arrow') : Configuration::get($this->name . '_show_arrow')));
$this->_html .='
</div>
<label>' . $this->l('Show navigation control: : ') . '</label>
<div class="margin-form">';
$this->_html .= $this->getSelectOptionsHtml(array(0 => 'No', 1 => 'Yes'), 'show_ctr', (Tools::getValue('title') ? Tools::getValue('show_ctr') : Configuration::get($this->name . '_show_ctr')));
$this->_html .='
</div>
<label>'.$this->l('Products Limit: ').'</label>
<div class="margin-form">
<input type = "text" name="p_limit" value ='.(Tools::getValue('p_limit')?Tools::getValue('p_limit'): Configuration::get($this->name.'_p_limit')).' ></input>
</div>
<input type="submit" name="submitPosTabCate" value="'.$this->l('Update').'" class="button" />
</fieldset>
</form>';
return $this->_html;
}
private function getCategoryOption($id_category = 1, $id_lang = false, $id_shop = false, $recursive = true) {
$cateCurrent = Configuration::get($this->name . '_list_cate');
$cateCurrent = explode(',', $cateCurrent);
$id_lang = $id_lang ? (int)$id_lang : (int)Context::getContext()->language->id;
$category = new Category((int)$id_category, (int)$id_lang, (int)$id_shop);
if (is_null($category->id))
return;
if ($recursive)
{
$children = Category::getChildren((int)$id_category, (int)$id_lang, true, (int)$id_shop);
$spacer = str_repeat(' ', $this->spacer_size * (int)$category->level_depth);
}
$shop = (object) Shop::getShop((int)$category->getShopID());
if (in_array('CAT'.(int)$category->id, $cateCurrent)) {
$this->_html .= '<option value="CAT'.(int)$category->id.'" selected ="selected" >'.(isset($spacer) ? $spacer : '').$category->name.' ('.$shop->name.')</option>';
} else {
$this->_html .= '<option value="CAT'.(int)$category->id.'">'.(isset($spacer) ? $spacer : '').$category->name.' ('.$shop->name.')</option>';
}
if (isset($children) && count($children))
foreach ($children as $child)
$this->getCategoryOption((int)$child['id_category'], (int)$id_lang, (int)$child['id_shop']);
}
}
类postabcateslider1扩展模块{
私人$U大小='5';
private$_postErrors=array();
private$\u html=null;
公共函数构造(){
$this->name='postabcateslider1';
$this->tab='front_office_features';
$this->version='1.5';
$this->author='posthemes';
$this->displayName=$this->l('Category Tabs Slider 1');
$this->description=$this->l('Category Tabs Slider 1');
父项::_构造();
}
公共函数安装(){
配置::updateValue($this->name.\u p\u在第行,4);
配置::updateValue($this->name.\u p_limit',30);
配置::updateValue($this->name.\u tab_effect','wiggle');
配置::updateValue($this->name.\u p\u在第行,4);
配置::updateValue($this->name.\u p\u width',150);
配置::updateValue($this->name.\u p_height',200);
配置::updateValue($this->name.\u min\u item',1);
配置::updateValue($this->name.\u max\u item',5);
配置::updateValue($this->name.\u speed\u slide',3000);
配置::updateValue($this->name.\u a\u speed',500);
配置::updateValue($this->name.\u显示箭头',0);
配置::updateValue($this->name.\u show\u ctr',0);
$arrayDefault=阵列('CAT3'、'CAT4'、'CAT5');
$catefault=内爆(“,”,$arrayDefault);
配置::updateGlobalValue($this->name.\u list\u cate',$cateDefault);
返回父::安装()
&&$this->registerHook('top')
/*&&&$this->registerHook('displayHome')*/
&&$this->registerHook('blockPosition2')
//&&$this->registerHook('displayHome')
&&$this->registerHook('header')
&&$this->registerHook('actionOrderStatusPostUpdate')
&&$this->registerHook('addproduct')
&&$this->registerHook('updateproduct')
&&$this->registerHook('deleteproduct');
}
公共函数卸载(){
配置::deleteByName($this->name.'u list_cate');
$this->_clearCache('postabcateslider1.tpl');
返回父::卸载();
}
公共函数psversion(){
$version=\u PS\u version;
$exp=$explode=explode(“.”,$version);
返回$exp[1];
}
公共函数hookHeader($params){
//如果($this->psversion()==5){
//$this->context->controller->addCSS(($this->_path)。'postabcateslider.css','all');
//$this->context->controller->addCSS(($this->_path)。'animate.delay.css','all');
//$this->context->controller->addCSS(($this->_path)。'animate.min.css','all');
//}其他{
//工具::addCSS($this->_path)。'postabcateslaider.css');
//工具::addCSS($this->_path)。'animate.delay.css');
//工具::addCSS($this->_path)。'animate.min.css');
// }
}
公共函数2($params){
$nb=Configuration::get($this->name.'.\u p_limit');
$product_on_row=Configuration::get($this->name.'\u p_on_row');
$arrayCategory=array();
$catSelected=Configuration::get($this->name.'u list_cate');
$cateArray=分解(“,”,$catSelected);
$id_lang=(int)Context::getContext()->language->id;
$id_shop=(int)Context::getContext()->shop->id;
$arrayProductCate=array();
foreach($cateArray作为$id\u类别){
$id_category=str_replace('CAT',''$id_category);
$category=新类别((int)$id\u category,(int)$id\u lang,(int)$id\u shop);
$categoryProducts=$category->getProducts($this->context->language->id,0,($nb?$nb:5),'date\u add','DESC');
if($categoryProducts){
$arrayProductCate[]=array('id'=>$id\U category,'name'=>$category->name,'product'=>$categoryProducts);
}
}
$options=array(
'p_width'=>Configuration::get($this->name.'p_width'),
'p_height'=>Configuration::get($this->name.'p_height'),
'speed\u slide'=>Configuration::get($this->name.'\u speed\u slide'),
'a_speed'=>Configuration::get($this->name.'u a_speed'),
'show_des'=>Configuration::get($this->name.'u show_des'),
'show_arrow'=>Configuration::get($this->name.'\u show_arrow'),
'show\u ctr'=>Configuration::get($this->name.'\u show\u ctr'),
'min\u item'=>Configuration::get($this->name.'\u min\u item'),
'max\u item'=>Configuration::get($this->name.'\u max\u item'),'show\u price'=>Configuration::get($this->name.\u show\u price'),
);
$this->context->smarty->assign('slideOptions',$options);
$this->smarty->assign(数组)(
'productCates'=>$arrayProductCate,
'add_prod_display'=>Configuration::get('PS_属性_类别_display'),
“homeSize”=>Image::getSize(ImageType::GetFormattedName('home')),
“行上的产品”=>行上的$product\U,
'tab_effect'=>Configuration::get($this->name.'tab_effect'),
'title'=>Configuration::get($this->name.'\u title'),
));
返回$this->display(_文件,'postabcateslider1.tpl');
}
公共函数getContent(){
$output=''.$this->displayName';
if(工具::isSubmit('submitPosTabCate')){
如果(!sizeof($this->\u postErrors))
$this->_postProcess();
否则{
弗雷奇(
$categoryProducts = $category->getProducts($this->context->language->id, 0, ($nb ? $nb : 5),'date_add','DESC');
if($categoryProducts) {
$arrayProductCate[] = array('id' => $id_category, 'name'=> $category->name, 'product' => $categoryProducts);
}
$categoryProducts = $category->getProducts($this->context->language->id, 0, ($nb ? $nb : 5));
shuffle($categoryProducts);
if($categoryProducts) {
$arrayProductCate[] = array('id' => $id_category, 'name'=> $category->name, 'product' => $categoryProducts);
}