Jump to content

[SOLVED] Can the special product block hide from certain category and the related product pages?


Recommended Posts

One of our company's supplier )Supplier A) forbidden us to have other supplier's products show on the page of their category page and product page since they are name brand. I have set up category 11, 12, and 13 to supplier A and 14, 15 16 to supplier B. How can I hide the special block when it is on supplier A's category (Category #11, 12 and 13)and the related product pages?

Thank you very much for the help.

Link to comment
Share on other sites

Change the hookRightColumn function in modules/blockspecials/blockspecials.php from:

function hookRightColumn($params)
{
   global $smarty;

   if ($special = Product::getRandomSpecial(intval($params['cookie']->id_lang)))
       $smarty->assign(array(
       'special' => $special,
       'oldPrice' => number_format($special['price'] + $special['reduction'], 2, '.', ''),
       'mediumSize' => Image::getSize('medium')));
   return $this->display(__FILE__, 'blockspecials.tpl');
}



to:

function hookRightColumn($params)
{
   global $smarty;

   if ($_GET['id_category'])
       $category = $_GET['id_category'];
   else if ($_GET['id_product'])
   {
       $product = new Product($_GET['id_product']);    
       $category = $product->id_category_default;
   }

   if ($special = Product::getRandomSpecial(intval($params['cookie']->id_lang)))
       $smarty->assign(array(
       'special' => $special,
       'oldPrice' => number_format($special['price'] + $special['reduction'], 2, '.', ''),
       'mediumSize' => Image::getSize('medium')),
       'category' => $category);
   return $this->display(__FILE__, 'blockspecials.tpl');
}



then put the following at the top of modules/blockspecials/blockspecials.tpl:

{if $category != 11 AND $category != 12 AND $category != 13}



and the following at the bottom:

{/if}

Link to comment
Share on other sites

Hi Rocky,

I did it 3 times, made sure I got your codes right. But I got error every time I did it.

Parse error: syntax error, unexpected T_DOUBLE_ARROW in /home/content/domain/modules/blockspecials/blockspecials.php on line 43

Where line 43 is
'category' => $category);

Could you please check your codes?

Thanks.

Link to comment
Share on other sites

He forgot a ), this should work.

function hookRightColumn($params)
{
   global $smarty;

   if ($_GET['id_category'])
       $category = $_GET['id_category'];
   else if ($_GET['id_product'])
   {
       $product = new Product($_GET['id_product']);    
       $category = $product->id_category_default;
   }

   if ($special = Product::getRandomSpecial(intval($params['cookie']->id_lang)))
       $smarty->assign(array(
       'special' => $special,
       'oldPrice' => number_format($special['price'] + $special['reduction'], 2, '.', ''),
       'mediumSize' => Image::getSize('medium'),
       'category' => $category));
   return $this->display(__FILE__, 'blockspecials.tpl');
} 



If you look at the error and where it is happening, you should / could be able to figure it out....

Link to comment
Share on other sites

He forgot a ), this should work.

function hookRightColumn($params)
{
   global $smarty;

   if ($_GET['id_category'])
       $category = $_GET['id_category'];
   else if ($_GET['id_product'])
   {
       $product = new Product($_GET['id_product']);    
       $category = $product->id_category_default;
   }

   if ($special = Product::getRandomSpecial(intval($params['cookie']->id_lang)))
       $smarty->assign(array(
       'special' => $special,
       'oldPrice' => number_format($special['price'] + $special['reduction'], 2, '.', ''),
       'mediumSize' => Image::getSize('medium')),
       'category' => $category));
   return $this->display(__FILE__, 'blockspecials.tpl');
} 



If you look at the error and where it is happening, you should / could be able to figure it out....



Sorry, I used the code you showed me above, i :-S t still has the same error, and my footer and the right column are both gone.
Link to comment
Share on other sites

It works now. Thank you very very much for you and Rocky's help.

Now I can sleep.

Sorry. One more question: Is there a list that I can see what kind of error and I can do whatever action to fix it? Kind of like a road map? I would like to learn more about the programming......

For example: Parse error: syntax error, unexpected T_DOUBLE_ARROW means I am missing a ).... something like that?

Link to comment
Share on other sites

It works now. Thank you very very much for you and Rocky's help.

Now I can sleep.

Sorry. One more question: Is there a list that I can see what kind of error and I can do whatever action to fix it? Kind of like a road map? I would like to learn more about the programming......

For example: Parse error: syntax error, unexpected T_DOUBLE_ARROW means I am missing a ).... something like that?



no, there is no such a list. You will fix this kind of issues very fast by just getting more experienced in PHP
Link to comment
Share on other sites

  • 2 years later...

Hi

 

Thanks it works,,I have another question.

 

I have created 3 category blocks with 5 categories each...

 

If i click on.. for suppose category with id 1 from Block 1...then the BLOCK 1 should only appear, Block 2 & block 3 Should dis appear after clicking catgeory with ID1..

 

Suggest me a code ..i know this can be done as the same way said above.. but how.. I know wee have to change file

/modules/blockcatgeory.php

/modules/blockcatgeory.tpl

 

But dont know what is the code and where to apply or how to change.

 

Pelase help me.

Link to comment
Share on other sites

×
×
  • Create New...