Jump to content

Ne pas afficher un bloc dans une catégorie [RESOLU]


pasta.pesto

Recommended Posts

Bonjour,

j'ai bricolé le bloc nouveau produits pour qu'il m'affiche toutes les photos de mes articles, il s'affiche donc partout, le problème c'est que ça ne m'intéresse pas qu'il s'affiche sur la page ou l'on voit déjà tous les produit c'est redondant ...

En résumé j'aimerais qu'il s'affiche partout sauf sur : http://*****/category.php?id_category=2 j'ai déjà essayé de mettre "category.php?id_category=2" mais ça n'est pas pris en compte cela c'est comme si je mettais rien

Je pense qu'il y a truc à bricolé dans le fichier blocknewproducts.php un etst pour vérifier si url=??? alors on affiche pas le bloc mais je ne sais pas comment récupérer l'url

J'ai un début de réponse ici : Lien

donc le code ressemblerais à ça (merci yoya971 :)) :

global $cookie;
$tmpCust = new Customer(intval($cookie->id_customer));
if(!$tmpCust->isMemberOfGroup(2)) return false;



si quelqu'un a une idée :)

--------------------------------------------------------------------------------------------------------------------------------

Edit : Bon ba j'ai tenté ça en farfouillant les variable du mode debug et ça à l'air de marché je continue de tester je mettrais résolu quand je suis sûre :
Fichier blocknewproducts.php

Rajouté au début et à la fin :

{if $id_category != 2} le code pour le bloc {/if}

Link to comment
Share on other sites

  • 5 months later...

Bonjour,
Je suis dans le même cas de figure.
Votre solution fonctionne t'-elle
Si oui, où placez vous le code?

Merci par avance,
Laurent


<?php

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

function __construct()
{
$this->name = 'blocknewproducts';
$this->tab = 'Blocks';
$this->version = 0.9;

parent::__construct();

$this->displayName = $this->l('New products block');
$this->description = $this->l('Displays a block featuring newly added products');
}

function install()
{
if (parent::install() == false
OR $this->registerHook('rightColumn') == false
OR Configuration::updateValue('NEW_PRODUCTS_NBR', 5) == false)
return false;
return true;
}

public function getContent()
{
$output = '

'.$this->displayName.'

';
if (Tools::isSubmit('submitBlockNewProducts'))
{
if (!$productNbr = Tools::getValue('productNbr') OR empty($productNbr))
$output .= '
'.$this->l('You should fill the "products displayed" field').'
';
elseif (intval($productNbr) == 0)
$output .= '
'.$this->l('Invalid number.').'
';
else
{
Configuration::updateValue('NEW_PRODUCTS_NBR', intval($productNbr));
$output .= '
ok.gifl('Confirmation').'" />'.$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('Products displayed').'

<input type="text" name="productNbr" value="'.intval(Configuration::get('NEW_PRODUCTS_NBR')).'" />

'.$this->l('Set the number of products to be displayed in this block').'



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


</form>';
return $output;
}

function hookRightColumn($params)
{
global $smarty;
$currency = new Currency(intval($params['cookie']->id_currency));
$newProducts = Product::getNewProducts(intval($params['cookie']->id_lang), 0, Configuration::get('NEW_PRODUCTS_NBR'));
$new_products = array();
if ($newProducts)
foreach ($newProducts AS $newProduct)
$new_products[] = $newProduct;

$smarty->assign(array(
'new_products' => $new_products,
'mediumSize' => Image::getSize('medium')));
return $this->display(__FILE__, 'blocknewproducts.tpl');
}

function hookLeftColumn($params)
{
return $this->hookRightColumn($params);
}
}


?>
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...