combinesom Posted April 11, 2011 Share Posted April 11, 2011 I have modified Homefeatured.php file so that show all the products of its category on the first page. The problem is that I can not do the pagination to the list of displayed products. Can anyone tell me what's next? Oh, and there is still a problem with the display of thumbnails.I was changed in homefeatured.php function hookHome($params) { global $smarty; $category = new Category(1); $nb = intval(Configuration::get('HOME_FEATURED_NBR')); $products = $category->getProducts(intval($params['cookie']->id_lang), 1, ($nb ? $nb : 10)); $smarty->assign(array('products' => $products, 'homeSize' => Image::getSize('home'))); return $this->display(__FILE__, 'homefeatured.tpl'); } to: function hookHome($params) { global $smarty; $category = new Category(1); $nb = intval(Configuration::get('HOME_FEATURED_NBR')); $products = Product::getProducts($params['cookie']->id_lang, 0, NULL, 'name', 'ASC', false, true); include(dirname(__FILE__).'/pagination.php'); $smarty->assign(array('products' => $products, 'homeSize' => Image::getSize('home'))); return $this->display(__FILE__, 'homefeatured.tpl'); } what's next? Please help me! Link to comment Share on other sites More sharing options...
combinesom Posted April 14, 2011 Author Share Posted April 14, 2011 Problem already solved. I modified the following files:modules/homefeatured/homefeatured.tpl - delete all content.modify index.php in root: <?php include(dirname(__FILE__).'/config/config.inc.php'); if(intval(Configuration::get('PS_REWRITING_SETTINGS')) === 1) $rewrited_url = __PS_BASE_URI__; include(dirname(__FILE__).'/header.php'); $smarty->assign('HOOK_HOME', Module::hookExec('home')); $smarty->display(_PS_THEME_DIR_.'index.tpl'); include(dirname(__FILE__).'/homefeaturedto.php'); include(dirname(__FILE__).'/footer.php'); ?> Create homefeaturedto.php in the root <?php include(dirname(__FILE__).'/product-sort.php'); $category = new Category(1); $nbProducts = $category->getProducts(NULL, NULL, NULL, $orderBy, $orderWay, true); include(dirname(__FILE__).'/pagination.php'); $smarty->assign('nb_products', $nbProducts); $cat_products = $category->getProducts(intval($cookie->id_lang), intval($p), intval($n), $orderBy, $orderWay); $smarty->assign(array( 'products' => (isset($cat_products) AND $cat_products) ? $cat_products : NULL, 'id_category' => intval($category->id), 'id_category_parent' => intval($category->id_parent), 'return_category_name' => Tools::safeOutput(Category::hideCategoryPosition($category->name)), 'path' => Tools::getPath(intval($category->id), $category->name) )); $smarty->display(_PS_THEME_DIR_.'homefeaturedto.tpl'); ?> create homefeaturedto.tpl in your themes: <!-- MODULE Home Featured Products --> {l s='New arrivals'} {if isset($products) AND $products} {assign var='liHeight' value=342} {assign var='nbItemsPerLine' value=4} {assign var='nbLi' value=$products|@count} {assign var='nbLines' value=$nbLi/$nbItemsPerLine|ceil} {assign var='ulHeight' value=$nbLines*$liHeight} {foreach from=$products item=product name=homeFeaturedProducts} {$product.name|truncate:27:'...'|escape:'htmlall':'UTF-8'} {$product.description_short|strip_tags|truncate:130:'...'} getImageLink($product.link_rewrite, $product.id_image, 'home')}" height="{$homeSize.height}" width="{$homeSize.width}" alt="{$product.name|escape:html:'UTF-8'}" /> {if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if} {l s='View'} {if ($product.quantity > 0 OR $product.allow_oosp) AND $product.customizable != 2} {l s='Add to cart'} {else} {l s='Add to cart'} {/if} {/foreach} {else} {l s='No new arrivals'} {/if} <!-- Pagination --> {if $products} {include file=$tpl_dir./pagination.tpl} {/if} <!-- /MODULE Home Featured Products --> I know that a better solution would be to create a modified module homefeatured, but that's beyond me ... I finished the economies and not IT. For sure will be a programmer who embrace it. Link to comment Share on other sites More sharing options...
alexcat Posted May 9, 2011 Share Posted May 9, 2011 anyone know how i could use this in prestashop 1.4?i have made modifications in this code and i have get to work in prestashop 1.3, but not in prestashop 1.4 Link to comment Share on other sites More sharing options...
Vikash Kumar Posted May 27, 2011 Share Posted May 27, 2011 prestashop 1.4modify modules/homefeatured/homefeatured.php function hookHome($params) { global $smarty; $category = new Category(1, Configuration::get('PS_LANG_DEFAULT')); $nb = (int)(Configuration::get('HOME_FEATURED_NBR')); $products = $category->getProducts((int)($params['cookie']->id_lang), 1, ($nb ? $nb : 10)); $smarty->assign(array( 'products' => $products, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'homeSize' => Image::getSize('home'))); return $this->display(__FILE__, 'homefeatured.tpl'); } to function hookHome($params) { global $smarty; $controller = new FrontController(); $controller->productSort(); $category = new Category(1, Configuration::get('PS_LANG_DEFAULT')); $nbProducts = $category->getProducts(NULL, NULL, NULL, $controller->orderBy, $controller->orderWay, true); $controller->pagination($nbProducts); $smarty->assign('nb_products', $nbProducts); $products = $category->getProducts((int)($params['cookie']->id_lang), intval($controller->p), intval($controller->n), $controller->orderBy, $controller->orderWay); $smarty->assign(array( 'products' => $products, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'homeSize' => Image::getSize('home'), 'id_category' => intval($category->id), 'id_category_parent' => intval($category->id_parent), 'return_category_name' => Tools::safeOutput(Category::hideCategoryPosition($category->name)), 'path' => Tools::getPath(intval($category->id), $category->name) )); return $this->display(__FILE__, 'homefeatured.tpl'); } modify modules/homefeatured/homefeatured.tplAdd {if isset($products) AND $products} {if isset($smarty.get.id_category) && $smarty.get.id_category && isset($category)} {assign var='requestPage' value=$link->getPaginationLink('category', $category, false, false, true, false)} {assign var='requestNb' value=$link->getPaginationLink('category', $category, true, false, false, true)} {else} {assign var='requestPage' value=$link->getPaginationLink(false, false, false, false, true, false)} {assign var='requestNb' value=$link->getPaginationLink(false, false, true, false, false, true)} {/if} <!-- Pagination --> {if $start!=$stop} {if $p != 1} {assign var='p_previous' value=$p-1} goPage($requestPage, $p_previous)}">« {l s='Previous'} {else} « {l s='Previous'} {/if} {if $start>3} goPage($requestPage, 1)}">1 ... {/if} {section name=pagination start=$start loop=$stop+1 step=1} {if $p == $smarty.section.pagination.index} {$p|escape:'htmlall':'UTF-8'} {else} goPage($requestPage, $smarty.section.pagination.index)}">{$smarty.section.pagination.index|escape:'htmlall':'UTF-8'} {/if} {/section} {if $pages_nb>$stop+2} ... goPage($requestPage, $pages_nb)}">{$pages_nb|intval} {/if} {if $pages_nb > 1 AND $p != $pages_nb} {assign var='p_next' value=$p+1} goPage($requestPage, $p_next)}">{l s='Next'} » {else} {l s='Next'} » {/if} {/if} {if $nb_products > 10} <form action="{if !is_array($requestNb)}{$requestNb}{else}{$requestNb.requestUrl}{/if}" method="get" class="pagination"> {if isset($query) AND $query}<input type="hidden" name="search_query" value="{$query|escape:'htmlall':'UTF-8'}" />{/if} {if isset($tag) AND $tag AND !is_array($tag)}<input type="hidden" name="tag" value="{$tag|escape:'htmlall':'UTF-8'}" />{/if} <input type="submit" class="button_mini" value="{l s='OK'}" /> {l s='items:'} {assign var="lastnValue" value="0"} {foreach from=$nArray item=nValue} {if $lastnValue <= $nb_products} {$nValue|escape:'htmlall':'UTF-8'} {/if} {assign var="lastnValue" value=$nValue} {/foreach} {if is_array($requestNb)} {foreach from=$requestNb item=requestValue key=requestKey} {if $requestKey != 'requestUrl'} <input type="hidden" name="{$requestKey|escape:'htmlall':'UTF-8'}" value="{$requestValue|escape:'htmlall':'UTF-8'}" /> {/if} {/foreach} {/if} </form> {/if} <!-- /Pagination --> {/if} 1 Link to comment Share on other sites More sharing options...
dambie Posted June 10, 2011 Share Posted June 10, 2011 Works fine, but i have error:Warning: Function hideCategoryPosition() is deprecated in \htdocs\shop\modules\homefeatured\homefeatured.php on line 111in \htdocs\shop\classes\Tools.php on line 1803 Link to comment Share on other sites More sharing options...
taywenxian87 Posted June 15, 2011 Share Posted June 15, 2011 Thanks combinesom for sharing your coding. I have applied them on my site (prestashop version 1.3) and it works, except for one part. My homefeatured module was previously modified in its css to display products in 3 columns. Now my pagination is adopting its css and the elements are displayed in blocks of 3 column. I have attached a photo. I believe this is because of the coding in homefeaturedto.tpl: <!-- Pagination --> {if $products} {include file=$tpl_dir./pagination.tpl} {/if}<!-- /MODULE Home Featured Products -->Can anyone advice me how to exclude the pagination from adopting the css coding of the homefeatured module? THANK YOU!!! Link to comment Share on other sites More sharing options...
combinesom Posted June 16, 2011 Author Share Posted June 16, 2011 Create your new pagination.tpl file and name it paginationto.tpl. Then change name of classes inside them and adjust to your page styles. Link to comment Share on other sites More sharing options...
ramin Posted August 11, 2012 Share Posted August 11, 2012 post number 4 is not correct can any body help for 1.4.6.2 ? Link to comment Share on other sites More sharing options...
fernandokerber Posted August 23, 2012 Share Posted August 23, 2012 Can we correct the code in post #4? Link to comment Share on other sites More sharing options...
slnko02 Posted September 5, 2012 Share Posted September 5, 2012 Me does not work any instructions. Does anyone done functional pagination for 1.4.8 Link to comment Share on other sites More sharing options...
oscarsilvaco Posted March 22, 2013 Share Posted March 22, 2013 Does anyone have a solution for 1.5.3.1? Link to comment Share on other sites More sharing options...
cristian_fd Posted March 25, 2013 Share Posted March 25, 2013 Prestashop 1.5.3.1 homefeatured.tpl <div id="featured-products_block_center" class="block products_block clearfix"> {if isset($products) AND $products} · · · {/if} </div> <div class="content_sortPagiBar homefeaturedPaged"> {include file="../../paginationHomeFeatured.tpl"} </div> paginationHomeFeatured.tpl {* * 2007-2012 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-2012 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 isset($no_follow) AND $no_follow} {assign var='no_follow_text' value='rel="nofollow"'} {else} {assign var='no_follow_text' value=''} {/if} {if isset($p) AND $p} {assign var='requestPage' value=$base_dir|cat:'index.php'} {assign var='requestNb' value=$base_dir|cat:'index.php'} <!-- Pagination --> <div id="pagination" class="pagination"> {if $start!=$stop} <ul class="pagination"> {if $p != 1} {assign var='p_previous' value=$p-1} <li id="pagination_previous"><a {$no_follow_text} href="{$link->goPage($requestPage, $p_previous)}">« {l s='Previous'}</a></li> {else} <li id="pagination_previous" class="disabled"><span>« {l s='Previous'}</span></li> {/if} {if $start==3} <li><a {$no_follow_text} href="{$link->goPage($requestPage, 1)}">1</a></li> <li><a {$no_follow_text} href="{$link->goPage($requestPage, 2)}">2</a></li> {/if} {if $start==2} <li><a {$no_follow_text} href="{$link->goPage($requestPage, 1)}">1</a></li> {/if} {if $start>3} <li><a {$no_follow_text} href="{$link->goPage($requestPage, 1)}">1</a></li> <li class="truncate">...</li> {/if} {section name=pagination start=$start loop=$stop+1 step=1} {if $p == $smarty.section.pagination.index} <li class="current"><span>{$p|escape:'htmlall':'UTF-8'}</span></li> {else} <li><a {$no_follow_text} href="{$link->goPage($requestPage, $smarty.section.pagination.index)}">{$smarty.section.pagination.index|escape:'htmlall':'UTF-8'}</a></li> {/if} {/section} {if $pages_nb>$stop+2} <li class="truncate">...</li> <li><a href="{$link->goPage($requestPage, $pages_nb)}">{$pages_nb|intval}</a></li> {/if} {if $pages_nb==$stop+1} <li><a href="{$link->goPage($requestPage, $pages_nb)}">{$pages_nb|intval}</a></li> {/if} {if $pages_nb==$stop+2} <li><a href="{$link->goPage($requestPage, $pages_nb-1)}">{$pages_nb-1|intval}</a></li> <li><a href="{$link->goPage($requestPage, $pages_nb)}">{$pages_nb|intval}</a></li> {/if} {if $pages_nb > 1 AND $p != $pages_nb} {assign var='p_next' value=$p+1} <li id="pagination_next"><a {$no_follow_text} href="{$link->goPage($requestPage, $p_next)}">{l s='Next'} »</a></li> {else} <li id="pagination_next" class="disabled"><span>{l s='Next'} »</span></li> {/if} </ul> {/if} {if $nb_products > $products_per_page} <form action="{if !is_array($requestNb)}{$requestNb}{else}{$requestNb.requestUrl}{/if}" method="get" class="pagination"> <p> {if isset($search_query) AND $search_query}<input type="hidden" name="search_query" value="{$search_query|escape:'htmlall':'UTF-8'}" />{/if} {if isset($tag) AND $tag AND !is_array($tag)}<input type="hidden" name="tag" value="{$tag|escape:'htmlall':'UTF-8'}" />{/if} <input type="submit" class="button_mini" value="{l s='OK'}" /> <label for="nb_item">{l s='items:'}</label> <select name="n" id="nb_item"> {assign var="lastnValue" value="0"} {foreach from=$nArray item=nValue} {if $lastnValue <= $nb_products} <option value="{$nValue|escape:'htmlall':'UTF-8'}" {if $n == $nValue}selected="selected"{/if}>{$nValue|escape:'htmlall':'UTF-8'}</option> {/if} {assign var="lastnValue" value=$nValue} {/foreach} </select> {if is_array($requestNb)} {foreach from=$requestNb item=requestValue key=requestKey} {if $requestKey != 'requestUrl'} <input type="hidden" name="{$requestKey|escape:'htmlall':'UTF-8'}" value="{$requestValue|escape:'htmlall':'UTF-8'}" /> {/if} {/foreach} {/if} </p> </form> {/if} </div> <!-- /Pagination --> {/if} Link to comment Share on other sites More sharing options...
gharibe68 Posted March 27, 2013 Share Posted March 27, 2013 Does anyone have a solution for 1.5.2? Link to comment Share on other sites More sharing options...
gharibe68 Posted March 29, 2013 Share Posted March 29, 2013 pls help me! i need pagination for 1.5.2 Link to comment Share on other sites More sharing options...
oscarsilvaco Posted April 1, 2013 Share Posted April 1, 2013 Thank you cristian_fd. I will try your code. Link to comment Share on other sites More sharing options...
oscarsilvaco Posted April 1, 2013 Share Posted April 1, 2013 Hi cristian_fd. Maybe can you help me with the code in homefeatured.php? thanks. =) Link to comment Share on other sites More sharing options...
luigicarlini Posted December 15, 2013 Share Posted December 15, 2013 Hi, cristian_fd solution doesn't work on PrestaShop™ 1.5.6.1 any solution? Link to comment Share on other sites More sharing options...
ALMAJ Posted January 26, 2014 Share Posted January 26, 2014 Any solution for Prestashop 1.5.6.2? Tanks Link to comment Share on other sites More sharing options...
vegaskev Posted June 27, 2014 Share Posted June 27, 2014 Anyone able to achieve pagination on home featured with Prestashop 1.6? Link to comment Share on other sites More sharing options...
p4t0X Posted September 2, 2014 Share Posted September 2, 2014 (edited) Anyone able to achieve pagination on home featured with Prestashop 1.6? Homefeatured pagination Prestashop 1.6 http://tinyurl.com/pe5m8ma ps: link is ok now, sorry []'s Edited September 3, 2014 by p4t0X (see edit history) Link to comment Share on other sites More sharing options...
TaloTejada Posted June 8, 2015 Share Posted June 8, 2015 Homefeatured pagination Prestashop 1.6 http://tinyurl.com/pe5m8ma ps: link is ok now, sorry []'s Muchas gracias, pero he copiado el código que indica y soy incapaz de que me haga algo, sigue sin que me funcione la paginación en homefeatured. Estoy usando la versión 1.6 de prestashop Link to comment Share on other sites More sharing options...
Lugorcorp Posted September 26, 2015 Share Posted September 26, 2015 Homefeatured pagination Prestashop 1.6 http://tinyurl.com/pe5m8ma ps: link is ok now, sorry []'s Thanks dude, the code is working for me, but the css is not very good, this is my result: http://i.imgur.com/4vGrsqX.png I'm going to see what can I do with the CCS Link to comment Share on other sites More sharing options...
ifecastro Posted December 19, 2018 Share Posted December 19, 2018 On 9/2/2014 at 10:56 PM, p4t0X said: Homefeatured pagination Prestashop 1.6 http://tinyurl.com/pe5m8ma ps: link is ok now, sorry []'s Hey bro, I tried it and got a blank homepage, what did I do wrong? Link to comment Share on other sites More sharing options...
ender666 Posted September 29, 2019 Share Posted September 29, 2019 On 9/2/2014 at 11:56 PM, p4t0X said: Homefeatured pagination Prestashop 1.6 http://tinyurl.com/pe5m8ma ps: link is ok now, sorry []'s thank you worked, but it is not random like before, it acts as normal category.. how to make homefeatured with pagination or better with infinite scroll and random? 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