Jump to content

Pagination homefeatured finally working


Recommended Posts

Hi guys, after a few hours, I found a code that allow me add a pagination on home section "homefeatured" but I can't edit the CSS as I wish.
 
The pagination tab is aligned to the left and I can't do that align to the right. You can see an example at the end of my page: http://drcollector.com.mx
 
I want to know if you can help me with the CSS :D
 
If you want to add a pagination on your home section you can find the code here: http://cadeseudeusagora.blogspot.com.br/2014/09/paginacao-homefeatured-prestashop-16.html is too easy to edit the code.
 
Replace the function called hookDisplayHome in homefeatured.php located in ROOT/modules/homefeatured/homefeatured.php
public function hookDisplayHome($params)
{
        $controller = new FrontController();
        $controller->productSort();                    
        $category = new Category(Context::getContext()->shop->getCategory(), (int)Context::getContext()->language->id);
        $nbProducts = $category->getProducts((int)Context::getContext()->language->id, NULL, NULL, 'position', NULL, true);
        $controller->pagination($nbProducts);
        $products = $category->getProducts((int)Context::getContext()->language->id, intval($controller->p), intval($controller->n), $controller->orderBy, $controller->orderWay);
               
        $this->smarty->assign(
                array(
                        'products' => $products,
                        'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'),
                        'homeSize' => Image::getSize(ImageType::getFormatedName('home')),
                        'nb_products' => $nbProducts,
                        'id_category' => (int)$category->id,
                        'id_category_parent' => (int)$category->id_parent,
                        'g_teste' => $_REQUEST,                        
                )
        );
               
        return $this->display(__FILE__, 'homefeatured.tpl' );
}

Then replace all the code from homefeatured.tpl located in ROOT/themes/YOUR_THEME/modules/homefeatured/homefeatured.tpl with this code

{if isset($products) && $products}
        {include file="$tpl_dir./product-list.tpl" class='homefeatured tab-pane' id='homefeatured'}    
        {include file="$tpl_dir./pagination.tpl"}
{else}
        <ul id="homefeatured" class="homefeatured tab-pane">
                <li class="alert alert-info">{l s='No featured products at this time.' mod='homefeatured'}</li>
        </ul>
{/if}

You will see something like this: http://i.imgur.com/4vGrsqX.png but if you want to remove the "Show all" button and the bottom text "showing 1 of x products" you can add this CSS:

.pagination { margin: 8px 0;} /*optional*/
.product-count { display: none !important; }
.showall button { display: none !important; }

I really hope you can help me.

 

BTW

The code is not mine, but the original file is in BR or Portuguese and sorry for my english D=

Link to comment
Share on other sites

  • 5 months later...
×
×
  • Create New...