Personalized product page in show.php

  • Posts: 34
  • Thank you received: 0
9 years 10 months ago #220713

-- HikaShop version -- : 2.6.0 Business
-- Joomla version -- : 3.4.4
-- PHP version -- : 5.5.29

Hello everyone,
I would like to display an image at the bottom of product page only in a specific category product.
I put this code in show.php:

<?php $category_name = JRequest::getInt('category_name'); if ($category_name == 'Partecipazioni') : ?><h3 style="text-align:center; margin-bottom:30px;">Alcuni esempi di colore e font</h3><img src="/ayro/media/com_hikashop/images/colori-font.jpg" /><?php endif; ?>

The fact is that it does not work and I do not understand why ... the image is displayed in every product, even in those who do not belong to the category "Partecipazioni".
Can anyone help me out?
Thank you and best regards,
Loredana

Last edit: 9 years 10 months ago by co88agency.

Please Log in or Create an account to join the conversation.

  • Posts: 12953
  • Thank you received: 1778
9 years 9 months ago #220715

Hello Loredana,
Using that kind of code through the "Show" file of the "Product" view of your front-end template via "Hikashop->Display->Views" will probably do the job :

if(isset($this->element->product_category_id) && $this->element->product_category_id == YOUR_CATEGORY_ID){?>
<h3 style = "text-align: center; margin-bottom: 30px;"> Some examples of color and font </ h3> <img src = "/ Ayro / media / com_hikashop / images / Color-font.jpg "/>
<?php
}
Don't forget to replace YOUR_CATEGORY_ID by your category ID that you can find via "Hikashop->Products->Categories".

Please Log in or Create an account to join the conversation.

  • Posts: 34
  • Thank you received: 0
9 years 9 months ago #220784

Thank you very very much!
Unfortunately it returns me an error... Complete code is:

<div class="row-fluid" style="margin-top:70px;">    

	<div class="span8" style="display:inline-block">
    <h3 style="text-align:center; line-height:25px; margin-bottom:30px;">Compila il form come indicato<br /><span style="font-size:18px;">inserisci i dati del tuo evento</span></h3>
	<?php

			}

			$this->setLayout('show_block_custom_item');

			echo $this->loadTemplate();

	if($this->params->get('show_price')){ ?>
    </div>
    
	<div class="span4" style="display:inline-block">    
    
	<?php if(isset($this->element->product_category_id) && $this->element->product_category_id == 40){?>
<h3 style = "text-align: center; margin-bottom: 30px;">Qualche esempio di font e colori</ h3> <img src = "/ayro/media/com_hikashop/images/colori-font.jpg "/>
<?php
}
	
	</div>

</div>

What is wrong?

Thanks and best regards,
Loredana

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
9 years 9 months ago #220787

Hi,

Please give us more details about the returned error.
This is maybe due to the "}" present before: $this->setLayout('show_block_custom_item');

Please Log in or Create an account to join the conversation.

  • Posts: 34
  • Thank you received: 0
9 years 9 months ago #220922

The error is reported to the line where there is the penultimate </div>, but it doesn't say what is error.

Thanks and best regards,
Loredana

Please Log in or Create an account to join the conversation.

  • Posts: 12953
  • Thank you received: 1778
9 years 9 months ago #220928

Hello Loredana,
Your issue is coming from your last 3 lines, you should replace these lines :

<?php
}
	
	</div>

</div>
By :
<?php
}?>
	
	</div>

</div>

Please Log in or Create an account to join the conversation.

  • Posts: 34
  • Thank you received: 0
9 years 9 months ago #221137

Thank you very much Mohamed!
The error is changed...
It's on lline 923...

<?php
content of the view removed by a moderator ; please do not paste entire view code.

Thank you very very much for your support...

Last edit: 9 years 9 months ago by Jerome. Reason: remove view content

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
9 years 9 months ago #221143

Hi,

You have to add another "}" right after the latest one in your code.

Please Log in or Create an account to join the conversation.

  • Posts: 34
  • Thank you received: 0
9 years 9 months ago #221252

Thank you very much. The error is ok now but I don't see image I want in category id 40...

Best regards,
Loredana

Please Log in or Create an account to join the conversation.

  • Posts: 12953
  • Thank you received: 1778
9 years 9 months ago #221286

Hello Loredana,
Then a solution can be to just check what you have on the $this->element->product_category_id variable to see if the category which have the ID number 40 is correctly called.
Using that php code will display the value of that variable for example :
echo 'Category ID : ' . $this->element->product_category_id;

Please Log in or Create an account to join the conversation.

  • Posts: 34
  • Thank you received: 0
9 years 9 months ago #221395

Finally!!! That's ok!!!!
Thank you very very very much... thank you thank you thank you...

Best regards,
Loredana

Please Log in or Create an account to join the conversation.

  • Posts: 34
  • Thank you received: 0
9 years 9 months ago #221954

I'm sorry, I'm still here...
Category number change costantly... why? How can I do?

Best regards,
Loredana

Please Log in or Create an account to join the conversation.

  • Posts: 26274
  • Thank you received: 4045
  • MODERATOR
9 years 9 months ago #221962

Hi,

What is a category number ?
What does "category number change constantly" mean ?

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 34
  • Thank you received: 0
9 years 9 months ago #222065

I used <php echo 'Category ID : ' . $this->element->product_category_id; ?> to find id category but every few time that id number changes...

Regards,
Loredana

Please Log in or Create an account to join the conversation.

  • Posts: 84306
  • Thank you received: 13701
  • MODERATOR
9 years 9 months ago #222071

You should use instead $this->element->category_id

The following user(s) said Thank You: co88agency

Please Log in or Create an account to join the conversation.

  • Posts: 34
  • Thank you received: 0
9 years 9 months ago #222169

Perfect! Now it works!
Thank you and best regards,
Loredana

Last edit: 9 years 9 months ago by co88agency.

Please Log in or Create an account to join the conversation.

Time to create page: 0.118 seconds
Powered by Kunena Forum