Jump to content

(SOLUCIONADO) dos modulos homefeatured en pagina inIcio


Javier Delgado

Recommended Posts

Hola a todos. He instalado un segundo modulo homefeatured en la pagina de inicio. Puedo configurar la cantidad de productos para cada modulo, lo que no llego es a seleccionar una determinada categoria a mostrar en un modulo en concreto. Os pongo el codigo php del archivo homefeatured_renov. Creo que en la ultima parte es donde deberia colocar el id de la categoria a mostrar, parece que es el ultimo parrafo que empieza por " function hookHome($params)", pero mis conocimientos de php son casi nulos.  Saludos y gracias

 

if (!defined('_PS_VERSION_'))
exit;
 
class homefeatured_renov extends Module
{
private $_html = '';
private $_postErrors = array();
 
function __construct()
{
$this->name = 'homefeatured_renov';
$this->tab = 'front_office_features';
$this->version = '0.9';
$this->author = 'PrestaShop';
$this->need_instance = 0;
 
parent::__construct();
 
$this->displayName = $this->l('Featured Products on the homepage');
$this->description = $this->l('Displays Featured Products in the middle of your homepage.');
}
 
function install()
{
if (!Configuration::updateValue('HOME_FEATURED_nbr_renov', 8) OR !parent::install() OR !$this->registerHook('home'))
return false;
return true;
}
 
public function getContent()
{
$output = '<h2>'.$this->displayName.'</h2>';
if (Tools::isSubmit('submithomefeatured_renov'))
{
$nbr_renov = (int)(Tools::getValue('nbr_renov'));
if (!$nbr_renov OR $nbr_renov <= 0 OR !Validate::isInt($nbr_renov))
$errors[] = $this->l('Invalid number of products');
else
Configuration::updateValue('HOME_FEATURED_nbr_renov', (int)($nbr_renov));
if (isset($errors) AND sizeof($errors))
$output .= $this->displayError(implode('<br />', $errors));
else
$output .= $this->displayConfirmation($this->l('Settings updated'));
}
return $output.$this->displayForm();
}
 
public function displayForm()
{
$output = '
<form action="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'" method="post">
<fieldset><legend><img src="'.$this->_path.'logo.gif" alt="" title="" />'.$this->l('Settings').'</legend>
<p>'.$this->l('In order to add products to your homepage, just add them to the "home" category.').'</p><br />
<label>'.$this->l('Number of products displayed').'</label>
<div class="margin-form">
<input type="text" size="5" name="nbr_renov" value="'.Tools::safeOutput(Tools::getValue('nbr_renov', (int)(Configuration::get('HOME_FEATURED_nbr_renov')))).'" />
<p class="clear">'.$this->l('The number of products displayed on homepage (default: 10).').'</p>
 
</div>
<center><input type="submit" name="submithomefeatured_renov" value="'.$this->l('Save').'" class="button" /></center>
</fieldset>
</form>';
return $output;
}
 
function hookHome($params)
{
global $smarty;
 
$category = new Category(1, Configuration::get('PS_LANG_DEFAULT'));
$nb = (int)(Configuration::get('HOME_FEATURED_nbr_renov'));
$products = $category->getProducts(intval($params['cookie']->id_lang), 1, ($nb ? $nb : 10), NULL, NULL, false, true, true, ($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_renov.tpl');
}
}
Edited by Javier Delgado (see edit history)
Link to comment
Share on other sites

Yo como segundo modulo, use este por ejemplo: http://www.prestashop.com/forums/topic/238176-module-random-homefeatured/

 

Y luego para cambiar la categoría, a mi este tema: http://www.prestashop.com/forums/topic/189846-how-to-change-category-from-home-to-something-else-in-homefeatured-module-in-15/ me sirvio, para lo que comentas.

 

Saludos,

Edited by Feliz Garcia (see edit history)
Link to comment
Share on other sites

  • nadie locked this topic
Guest
This topic is now closed to further replies.
×
×
  • Create New...