radhaumashankar Posted July 10, 2017 Share Posted July 10, 2017 I want to duplicate home featured module to display products from more than one categories, I mean, Home featured1 *products Home featured 2 *products how do i do that , can u guys show me step by step. Link to comment Share on other sites More sharing options...
radhaumashankar Posted July 10, 2017 Author Share Posted July 10, 2017 Well i duplicated home featured module. but i had one more problem, the duplicated module shows up the products,but it is totally out of style. it is displaying products as blocks,i mean not inline. how to sort this out. Link to comment Share on other sites More sharing options...
Scully Posted July 10, 2017 Share Posted July 10, 2017 My guess: The corresponding CSS file is only loaded on the startpage. If you are not on the startpage, this file is missing. Hence the strange formatting. Link to comment Share on other sites More sharing options...
radhaumashankar Posted July 11, 2017 Author Share Posted July 11, 2017 What do you mean by start page. sorry,i did not get you. Link to comment Share on other sites More sharing options...
Scully Posted July 11, 2017 Share Posted July 11, 2017 The startpage means the root or main folder of your shop. If you haven't installed prestashop in a subdirectory, it usually is the same as your domain name. Homeslider is written in a way it works only on the startpage. If you want a copy of this module, you have to change more of the php code. Just ONE example here: public function hookdisplayHeader($params) { if (!isset($this->context->controller->php_self) || $this->context->controller->php_self != 'index') return; $this->context->controller->addCSS($this->_path.'homeslider.css'); $this->context->controller->addJS($this->_path.'js/homeslider.js'); $this->context->controller->addJqueryPlugin(array('bxslider')); $config = $this->getConfigFieldsValues(); $slider = array( 'width' => $config['HOMESLIDER_WIDTH'], 'speed' => $config['HOMESLIDER_SPEED'], 'pause' => $config['HOMESLIDER_PAUSE'], 'loop' => (bool)$config['HOMESLIDER_LOOP'], ); $this->smarty->assign('homeslider', $slider); return $this->display(__FILE__, 'header.tpl'); } The if condition above just after beginning of hookdisplayHeader checks if the request comes from antother page than "index" which would be the homepage. If this is the case, it just returns without loading the corresponding css and javascript files. Link to comment Share on other sites More sharing options...
radhaumashankar Posted July 11, 2017 Author Share Posted July 11, 2017 thank you for reply Link to comment Share on other sites More sharing options...
Scully Posted July 12, 2017 Share Posted July 12, 2017 Very good. If its working for you, can you add 'SOLVED' to the topic. Use "More Reply Options" to get there. Link to comment Share on other sites More sharing options...
Chang Posted July 23, 2018 Share Posted July 23, 2018 (edited) hi, i have dupplicate homefeatured, i have change all "homefeatured" to "homefeatured2", i change class too, i have change the link for to find product-list.css so, i have homefeatured 2 in tab in my homepage, that's ok, but my tab is always open... i have on it since 2 days lol so if someone can help me, because i am near to find the solution but.. nope sorry for my english Edited July 23, 2018 by Chang (see edit history) Link to comment Share on other sites More sharing options...
Chang Posted July 23, 2018 Share Posted July 23, 2018 (edited) he does not crush the other tabs i am on last version of ps 1.6 theme defaut-bootstrap my homefeaturedxxx.php: <?php /* * 2007-2016 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 [email protected] 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 <[email protected]> * @copyright 2007-2016 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('_PS_VERSION_')) exit; class HomeFeaturedxxx extends Module { protected static $cache_products; public function __construct() { $this->name = 'homefeaturedxxx'; $this->tab = 'front_office_features'; $this->version = 'xxx'; $this->author = 'PrestaShop'; $this->need_instance = 0; $this->bootstrap = true; parent::__construct(); $this->displayName = $this->l('Featured products on the homepage'); $this->description = $this->l('Displays featured products in the central column of your homepage.'); $this->ps_versions_compliancy = array('min' => '1.6', 'max' => '1.6.99.99'); } public function install() { $this->_clearCache('*'); Configuration::updateValue('HOME_FEATURED_NBRxxx', 8); Configuration::updateValue('HOME_FEATURED_CATxxx', (int)Context::getContext()->shop->getCategory()); Configuration::updateValue('HOME_FEATURED_RANDOMIZExxx', false); if (!parent::install() || !$this->registerHook('header') || !$this->registerHook('addproduct') || !$this->registerHook('updateproduct') || !$this->registerHook('deleteproduct') || !$this->registerHook('categoryUpdate') || !$this->registerHook('displayHomeTab') || !$this->registerHook('displayHomeTabContent') ) return false; return true; } public function uninstall() { $this->_clearCache('*'); return parent::uninstall(); } public function getContent() { $output = ''; $errors = array(); if (Tools::isSubmit('submitHomeFeaturedxxx')) { $nbr = Tools::getValue('HOME_FEATURED_NBRxxx'); if (!Validate::isInt($nbr) || $nbr <= 0) $errors[] = $this->l('The number of products is invalid. Please enter a positive number.'); $cat = Tools::getValue('HOME_FEATURED_CATxxx'); if (!Validate::isInt($cat) || $cat <= 0) $errors[] = $this->l('The category ID is invalid. Please choose an existing category ID.'); $rand = Tools::getValue('HOME_FEATURED_RANDOMIZExxx'); if (!Validate::isBool($rand)) $errors[] = $this->l('Invalid value for the "randomize" flag.'); if (isset($errors) && count($errors)) $output = $this->displayError(implode('<br />', $errors)); else { Configuration::updateValue('HOME_FEATURED_NBRxxx', (int)$nbr); Configuration::updateValue('HOME_FEATURED_CATxxx', (int)$cat); Configuration::updateValue('HOME_FEATURED_RANDOMIZExxx', (bool)$rand); Tools::clearCache(Context::getContext()->smarty, $this->getTemplatePath('homefeaturedxxx.tpl')); $output = $this->displayConfirmation($this->l('Your settings have been updated.')); } } return $output.$this->renderForm(); } public function hookDisplayHeader($params) { $this->hookHeader($params); } public function hookHeader($params) { if (isset($this->context->controller->php_self) && $this->context->controller->php_self == '/www/prestamc/index') $this->context->controller->addCSS(_THEME_CSS_DIR_.'/www/prestamc/themes/default-bootstrap/css/product_list.css'); $this->context->controller->addCSS(($this->_path).'/www/prestamc/themes/default-bootstrap/css/modules/homefeatured/homefeatured.css', 'all'); } public function _cacheProducts() { if (!isset(HomeFeaturedxxx::$cache_products)) { $category = new Category((int)Configuration::get('HOME_FEATURED_CATxxx'), (int)Context::getContext()->language->id); $nb = (int)Configuration::get('HOME_FEATURED_NBRxxx'); if (Configuration::get('HOME_FEATURED_RANDOMIZExxx')) HomeFeaturedxxx::$cache_products = $category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 8), null, null, false, true, true, ($nb ? $nb : 8)); else HomeFeaturedxxx::$cache_products = $category->getProducts((int)Context::getContext()->language->id, 1, ($nb ? $nb : 8), 'position'); } if (HomeFeaturedxxx::$cache_products === false || empty(HomeFeaturedxxx::$cache_products)) return false; } public function hookDisplayHomeTab($params) { if (!$this->isCached('tab.tpl', $this->getCacheId('homefeaturedxxx-tab'))) $this->_cacheProducts(); return $this->display(__FILE__, 'tab.tpl', $this->getCacheId('homefeaturedxxx-tab')); } public function hookDisplayHome($params) { if (!$this->isCached('homefeaturedxxx.tpl', $this->getCacheId())) { $this->_cacheProducts(); $this->smarty->assign( array( 'products' => HomeFeaturedxxx::$cache_products, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), ) ); } return $this->display(__FILE__, 'homefeaturedxxx.tpl', $this->getCacheId()); } public function hookDisplayHomeTabContent($params) { return $this->hookDisplayHome($params); } public function hookAddProduct($params) { $this->_clearCache('*'); } public function hookUpdateProduct($params) { $this->_clearCache('*'); } public function hookDeleteProduct($params) { $this->_clearCache('*'); } public function hookCategoryUpdate($params) { $this->_clearCache('*'); } public function _clearCache($template, $cache_id = NULL, $compile_id = NULL) { parent::_clearCache('homefeaturedxxx.tpl'); parent::_clearCache('tab.tpl', 'homefeaturedxxx-tab'); } public function renderForm() { $fields_form = array( 'form' => array( 'legend' => array( 'title' => $this->l('Settings'), 'icon' => 'icon-cogs' ), 'description' => $this->l('To add products to your homepage, simply add them to the corresponding product category (default: "Home").'), 'input' => array( array( 'type' => 'text', 'label' => $this->l('Number of products to be displayed'), 'name' => 'HOME_FEATURED_NBRxxx', 'class' => 'fixed-width-xs', 'desc' => $this->l('Set the number of products that you would like to display on homepage (default: 8).'), ), array( 'type' => 'text', 'label' => $this->l('Category from which to pick products to be displayed'), 'name' => 'HOME_FEATURED_CATxxx', 'class' => 'fixed-width-xs', 'desc' => $this->l('Choose the category ID of the products that you would like to display on homepage (default: 2 for "Home").'), ), array( 'type' => 'switch', 'label' => $this->l('Randomly display featured products'), 'name' => 'HOME_FEATURED_RANDOMIZExxx', 'class' => 'fixed-width-xs', 'desc' => $this->l('Enable if you wish the products to be displayed randomly (default: no).'), 'values' => array( array( 'id' => 'active_on', 'value' => 1, 'label' => $this->l('Yes') ), array( 'id' => 'active_off', 'value' => 0, 'label' => $this->l('No') ) ), ), ), 'submit' => array( 'title' => $this->l('Save'), ) ), ); $helper = new HelperForm(); $helper->show_toolbar = false; $helper->table = $this->table; $lang = new Language((int)Configuration::get('PS_LANG_DEFAULT')); $helper->default_form_language = $lang->id; $helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0; $this->fields_form = array(); $helper->id = (int)Tools::getValue('id_carrier'); $helper->identifier = $this->identifier; $helper->submit_action = 'submitHomeFeaturedxxx'; $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false).'&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name; $helper->token = Tools::getAdminTokenLite('AdminModules'); $helper->tpl_vars = array( 'fields_value' => $this->getConfigFieldsValues(), 'languages' => $this->context->controller->getLanguages(), 'id_language' => $this->context->language->id ); return $helper->generateForm(array($fields_form)); } public function getConfigFieldsValues() { return array( 'HOME_FEATURED_NBRxxx' => Tools::getValue('HOME_FEATURED_NBRxxx', (int)Configuration::get('HOME_FEATURED_NBRxxx')), 'HOME_FEATURED_CATxxx' => Tools::getValue('HOME_FEATURED_CATxxx', (int)Configuration::get('HOME_FEATURED_CATxxx')), 'HOME_FEATURED_RANDOMIZExxx' => Tools::getValue('HOME_FEATURED_RANDOMIZExxx', (bool)Configuration::get('HOME_FEATURED_RANDOMIZExxx')), ); } } Edited July 23, 2018 by Chang (see edit history) Link to comment Share on other sites More sharing options...
Chang Posted July 23, 2018 Share Posted July 23, 2018 (edited) maybe i must change tab.tpl too..? <li><a data-toggle="tab" href="#homefeaturedxxx" class="homefeaturedxxx">{l s='Popular' mod='homefeaturedxxx'}</a></li> i'm lost ok i look the other module and i think i don't must change tab i look again with developper on firefox and i saw the id of my new tab is "featured-products_block_center" and class is "block products_block clearfix" so its different of the other tab, i look in this direction.. Edited July 23, 2018 by Chang (see edit history) Link to comment Share on other sites More sharing options...
Chang Posted July 23, 2018 Share Posted July 23, 2018 hahaa my new tab is on the other tab !! i win !! but again a problem on css.. Link to comment Share on other sites More sharing options...
Chang Posted July 23, 2018 Share Posted July 23, 2018 when i clic on add to cart on my product, it say "product not found" but picture is ok, the link for product is ok... when i put my mouse on button there is "&add" at the end of link... not "&add" on the other link of other product in other tab.. i'm very lost lol Link to comment Share on other sites More sharing options...
Chang Posted July 23, 2018 Share Posted July 23, 2018 my homefeaturedxxx.tpl if someone can help me ... its like i throw a sos bottle in sea lol <!-- MODULE Home Featured Products --> <div id="homefeaturedxxx" class="product_list grid row homefeatured tab-pane"> <h4 class="title_block">{l s='Featured products' mod='homefeaturedxxx'}</h4> {if isset($products) AND $products} <div class="block_content"> {assign var='liHeight' value=250} {assign var='nbItemsPerLine' value=4} {assign var='nbLi' value=$products|@count} {math equation="nbLi/nbItemsPerLine" nbLi=$nbLi nbItemsPerLine=$nbItemsPerLine assign=nbLines} {math equation="nbLines*liHeight" nbLines=$nbLines|ceil liHeight=$liHeight assign=ulHeight} <ul style="height:{$ulHeight|escape:'html'}px;"> {foreach from=$products item=product name=homeFeaturedProductsxxx} {math equation="(total%perLine)" total=$smarty.foreach.homeFeaturedProductsxxx.total perLine=$nbItemsPerLine assign=totModulo} {if $totModulo == 0}{assign var='totModulo' value=$nbItemsPerLine}{/if} <li class="ajax_block_product {if $smarty.foreach.homeFeaturedProductsxxx.first}first_item{elseif $smarty.foreach.homeFeaturedProductsxxx.last}last_item{else}item{/if} {if $smarty.foreach.homeFeaturedProductsxxx.iteration%$nbItemsPerLine == 0}last_item_of_line{elseif $smarty.foreach.homeFeaturedProductsxxx.iteration%$nbItemsPerLine == 1} {/if} {if $smarty.foreach.homeFeaturedProductsxxx.iteration > ($smarty.foreach.homeFeaturedProductsxxx.total - $totModulo)}last_line{/if}"> <a href="{$product.link|escape:'html'}" title="{$product.name|escape:html:'UTF-8'}" class="product_image"><img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'home_default')|escape:'html'}" height="{$homeSize.height}" width="{$homeSize.width}" alt="{$product.name|escape:html:'UTF-8'}" />{if isset($product.new) && $product.new == 1}<span class="new">{l s='New' mod='homefeaturedxxx'}</span>{/if}</a> <h5 class="s_title_block"><a href="{$product.link|escape:'html'}" title="{$product.name|truncate:50:'...'|escape:'html':'UTF-8'}">{$product.name|truncate:35:'...'|escape:'html':'UTF-8'}</a></h5> <div class="product_desc"><a href="{$product.link|escape:'html'}" title="{l s='More' mod='homefeaturedxxx'}">{$product.description_short|strip_tags|truncate:65:'...'}</a></div> <div> <a class="lnk_more" href="{$product.link|escape:'html'}" title="{l s='View' mod='homefeaturedxxx'}">{l s='View' mod='homefeaturedxxx'}</a> {if $product.show_price AND !isset($restricted_country_mode) AND !$PS_CATALOG_MODE}<p class="price_container"><span class="price">{if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if}</span></p>{else}<div style="height:21px;"></div>{/if} {if ($product.id_product_attribute == 0 OR (isset($add_prod_display) AND ($add_prod_display == 1))) AND $product.available_for_order AND !isset($restricted_country_mode) AND $product.minimal_quantity == 1 AND $product.customizable != 2 AND !$PS_CATALOG_MODE} {if ($product.quantity > 0 OR $product.allow_oosp)} <a class="exclusive ajax_add_to_cart_button" rel="ajax_id_product_{$product.id_product}" href="{$link->getPageLink('cart')|escape:'html'}?qty=1&id_product={$product.id_product}&token={$static_token}&add" title="{l s='Add to cart' mod='homefeaturedxxx'}">{l s='Add to cart' mod='homefeaturedxxx'}</a> {else} <span class="exclusive">{l s='Add to cart' mod='homefeaturedxxx'}</span> {/if} {else} <div style="height:23px;"></div> {/if} </div> </li> {/foreach} </ul> </div> {else} <p>{l s='No featured products' mod='homefeaturedxxx'}</p> {/if} </div> <!-- /MODULE Home Featured Products --> Link to comment Share on other sites More sharing options...
Chang Posted July 23, 2018 Share Posted July 23, 2018 in developper firefox i saw the others tab are <ul id="...........> and for my new module is <div id=".....> my module is not in the list ...? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now