Jump to content
Sign in to follow this  
devsoft

[Module] Carousel 1.0RC5

Recommended Posts

This module displays new products in the middle of your homepage as Carousel(see photo).
You can change number of products in admin page. Tested on Prestashop 1.3.3
Download

- new style and big image animation.
- includes kennyh modification

36408_XLzWIX34vwK2SUUHfvuD_t

Share this post


Link to post
Share on other sites

Hey
Thanks for the module , I added input to choose category by id in the BO instead of new products.


<?php

if (!defined('_CAN_LOAD_FILES_'))
   exit;

class Carousel extends Module
{
   private $_html = '';
   private $_postErrors = array();

   function __construct()
   {
       $this->name = 'carousel';
       $this->tab = 'front_office_features';
       $this->version = '0.7RC';

       parent::__construct();

       $this->displayName = $this->l('Carousel');
       $this->description = $this->l('Displays New Products on  homepage');
   }

   function install()
   {



       if (!Configuration::updateValue('CAROUSEL_NBR', 5) OR !parent::install() OR !$this->registerHook('home'))
           return false;
           if (!Configuration::updateValue('HOME_FEATURED_CATEG', 1)) // defaults to home category
           return false;
       return true;
   }


   public function getContent()
   {
       $output = ''.$this->displayName.'';
       if (Tools::isSubmit('submitHomeFeatured'))
       {

         $cat = intval(Tools::getValue('categ'));
           $nbr = (int)(Tools::getValue('nbr'));
              $category = intval(Tools::getValue('category'));
           if (!$nbr OR $nbr <= 0 OR !Validate::isInt($nbr))
               $errors[] = $this->l('Invalid number of product');
           else
             Configuration::updateValue('HOME_FEATURED_CATEG', $cat);
               Configuration::updateValue('CAROUSEL_NBR', (int)($nbr));
           if (isset($errors) AND sizeof($errors))
               $output .= $this->displayError(implode('
', $errors));
           else
               $output .= $this->displayConfirmation($this->l('Settings updated'));
       }
       return $output.$this->displayForm();
   }

   public function displayForm()
   {
       $output = '
       <form action="'.$_SERVER['REQUEST_URI'].'" method="post">
_path.'logo.gif" alt="" title="" />'.$this->l('Settings').'
'.$this->l('The product category to show products from').'                                    

                   <input type="text" size="5" name="categ" value="'.Tools::getValue('categ', Configuration::get('HOME_FEATURED_CATEG')).'" />                    

'.$this->l('Number of product displayed').'

                   <input type="text" size="5" name="nbr" value="'.Tools::getValue('nbr', (int)(Configuration::get('CAROUSEL_NBR'))).'" />



<input type="submit" name="submitHomeFeatured" value="'.$this->l('Save').'" class="button" />

       </form>';
       return $output;
   }

   function hookHome ($params)
   {
       global $smarty;
       $cat = intval(Configuration::get('HOME_FEATURED_CATEG')); // category selected in BackOffice
       $category = new Category($cat);
       $nb = intval(Configuration::get('CAROUSEL_NBR'));
       $products = $category->getProducts(intval($params['cookie']->id_lang), 1, ($nb ? $nb : 50));
   if ($newProducts AND Configuration::get('PS_BLOCK_CAROUSEL_DISPLAY'))
           return;

           $smarty->assign(array(
           'category' => $category,
           'products' => $products, 'homeSize' => Image::getSize('home'),
           'currency' => new Currency(intval($params['cart']->id_currency)),
           'lang' => Language::getIsoById(intval($params['cookie']->id_lang)),
           'productNumber' => count($products)
       ));
        $smarty->assign('this_path', $this->_path);
       return $this->display(__FILE__, 'carousel.tpl');

   }
}





replace carousel.php with above to view products in your category

Share this post


Link to post
Share on other sites

If I do kennyh modifications, I get the module tab working again BUT in the module backoffice I have the error "Parse error(s) in module(s): 1. carousel"

ALSO: Is it compatible for more than one language? I have 3 languages activated in my store.

Share this post


Link to post
Share on other sites

Try now it's allready with kennyh modification. It includes only english language.

Share this post


Link to post
Share on other sites

Works OK but it could be nice if the big picture change as a slideshow, now big picture change only on clic

Share this post


Link to post
Share on other sites

The link is effectively dead.

 

Please remove it.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More