Jump to content

Changing Pagination on product pages 1.4


Recommended Posts

I would like to change the number of products selected to display from the bottom drop down box on each product page. i.e. 12, 24 , 48!

 

I change Back Office - Preferences - Products = 24 items!

 

I search my FrontController.php and not find code to change, this is my code:

<?php

class FrontController extends FrontControllerCore
{
   public function displayHeader()
   {
       global $css_files, $js_files;

       if (!self::$initialized)
           $this->init();

       // P3P Policies (http://www.w3.org/TR/2002/REC-P3P-20020416/#compact_policies)
       header('P3P: CP="IDC DSP COR CURa ADMa OUR IND PHY ONL COM STA"');

       /* Hooks are volontary out the initialize array (need those variables already assigned) */
       self::$smarty->assign(array(
           'time' => time(),
           'static_token' => Tools::getToken(false),
           'token' => Tools::getToken(),
           'logo_image_width' => Configuration::get('SHOP_LOGO_WIDTH'),
           'logo_image_height' => Configuration::get('SHOP_LOGO_HEIGHT'),
           'priceDisplayPrecision' => _PS_PRICE_DISPLAY_PRECISION_,
           'content_only' => (int)(Tools::getValue('content_only'))
       ));
       self::$smarty->assign(array(
           'HOOK_INVERTUS_AUCTION' => Module::hookExec('invertus_auction'), // invertus
           'HOOK_HEADER' => Module::hookExec('header'),
           'HOOK_TOP' => Module::hookExec('top'),
           'HOOK_LEFT_COLUMN' => Module::hookExec('leftColumn')
       ));

       if ((Configuration::get('PS_CSS_THEME_CACHE') OR Configuration::get('PS_JS_THEME_CACHE')) AND is_writable(_PS_THEME_DIR_.'cache'))
       {
           // CSS compressor management
           if (Configuration::get('PS_CSS_THEME_CACHE'))
               Tools::cccCss();

           //JS compressor management
           if (Configuration::get('PS_JS_THEME_CACHE'))
               Tools::cccJs();
       }

       self::$smarty->assign('css_files', $css_files);
       self::$smarty->assign('js_files', array_unique($js_files));
       self::$smarty->display(_PS_THEME_DIR_.'header.tpl');
   }
}

 

And i found this code on prestashop forums, but I don't understand how cnahge, because my FrontController.php from Auction script....

<?php

class FrontController extends FrontControllerCore
{
   public function pagination($nbProducts = 12)
   {
       if (!self::$initialized)
           $this->init();

       $nArray = (int)(Configuration::get('PS_PRODUCTS_PER_PAGE')) != 12 ? array((int)(Configuration::get('PS_PRODUCTS_PER_PAGE')), 12, 24, 36, 48, 60) : array(12, 24, 36, 48, 60);
       asort($nArray);
       $this->n = abs((int)(Tools::getValue('n', ((isset(self::$cookie->nb_item_per_page) AND self::$cookie->nb_item_per_page >= 12) ? self::$cookie->nb_item_per_page : (int)(Configuration::get('PS_PRODUCTS_PER_PAGE'))))));
       $this->p = abs((int)(Tools::getValue('p', 1)));
       $range = 2; /* how many pages around page selected */

       if ($this->p < 0)
           $this->p = 0;

       if (isset(self::$cookie->nb_item_per_page) AND $this->n != self::$cookie->nb_item_per_page AND in_array($this->n, $nArray))
           self::$cookie->nb_item_per_page = $this->n;

       if ($this->p > ($nbProducts / $this->n))
           $this->p = ceil($nbProducts / $this->n);
       $pages_nb = ceil($nbProducts / (int)($this->n));

       $start = (int)($this->p - $range);
       if ($start < 1)
           $start = 1;
       $stop = (int)($this->p + $range);
       if ($stop > $pages_nb)
           $stop = (int)($pages_nb);
       self::$smarty->assign('nb_products', $nbProducts);
       $pagination_infos = array(
           'pages_nb' => (int)($pages_nb),
           'p' => (int)($this->p),
           'n' => (int)($this->n),
           'nArray' => $nArray,
           'range' => (int)($range),
           'start' => (int)($start),
           'stop' => (int)($stop)
       );
       self::$smarty->assign($pagination_infos);
   }
}

Help!

 

Bojan

Link to comment
Share on other sites

×
×
  • Create New...