Category in product display with custom <hr>

  • Posts: 441
  • Thank you received: 24
11 years 6 months ago #72274

ok this one is for price if not possible not possible.
what my client wants is that in the web wich has 8 categories, each one has a color code
this color is displayed underlining the category with a <hr> wich has different colors depending on the category.
and this one should be displayed in product description. The second part is solved and i have the category in product description it´s just the underline changing depending on category what i need.
Thank you

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

  • Posts: 81604
  • Thank you received: 13082
  • MODERATOR
11 years 6 months ago #72479

I don't understand.
If the hr must be in the description, why not directly add it in the description and add to it a style attribute in order to define the color ?

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

  • Posts: 441
  • Thank you received: 24
11 years 6 months ago #73175

I mean i have in my product view 4 parts top, right, left and bottom.
in top part all the width of the page is covered with the category name wich the product belongs to.
under it there is a custom <hr> with an image.
what i want is that the image changes when category changes.

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

  • Posts: 81604
  • Thank you received: 13082
  • MODERATOR
11 years 6 months ago #73433

So I understand that the hr and the image are added by yourself with custom code.
Could you tell us what code you're using for that ?

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

  • Posts: 441
  • Thank you received: 24
11 years 6 months ago #73668

in the show.php of the product i just added the category php line and under it an <hr class="line">
what i dont know how to do is that this hr changes depending on the category.

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

  • Posts: 81604
  • Thank you received: 13082
  • MODERATOR
11 years 6 months ago #73986

if you have the category data in a variable called $category, you can do like that:
if($category->category_name="My category"){
echo '<hr class="line" style="color:red;">';
}elseif($category->category_name="My second category"){
echo '<hr class="line" style="color:blue;">';
}else{
echo '<hr class="line" style="color:black;">';
}

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

  • Posts: 441
  • Thank you received: 24
11 years 5 months ago #74460

we are very close, first i should insert the code in the show.php or in other php?
second the color of the hr is a custom image so it should be something like hr class="line1" and the line2 depending on the category.
Thank you very much

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

  • Posts: 81604
  • Thank you received: 13082
  • MODERATOR
11 years 5 months ago #74890

In the show.php yes.

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

  • Posts: 441
  • Thank you received: 24
11 years 5 months ago #74982

so in the style as it is an image i should put style="background=url("whatever");"

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

  • Posts: 441
  • Thank you received: 24
11 years 5 months ago #75590

it did not work, i created this in show_default.php and i added the code after the line of category but something is wrong it stops reading in first case
<div id="hikashop_product_top_part" class="hikashop_product_top_part">
<h2>
<span>
<?php
foreach($this->categories as $category) echo $category->category_name;
?>
</span><br/>

</h2>
<?php if($category->category_name="Linea Esencial"){
echo '<hr class="linea">';
}elseif($category->category_name="Linea Equilibrante"){
echo '<hr class="linea2">';
}elseif($category->category_name="Linea Multivitaminas"){
echo '<hr class="linea3">';
}elseif($category->category_name="Linea Multiefectos"){
echo '<hr class="linea4">';
}elseif($category->category_name="Linea de Barros"){
echo '<hr class="linea5">';
}elseif($category->category_name="Linea Spa Corporal"){
echo '<hr class="linea6">';
}elseif($category->category_name="Manicura & Pedicura"){
echo '<hr class="linea7">';
}elseif($category->category_name="Linea Spa Capilar"){
echo '<hr class="linea8">';
}?>

</div>
only first i showing in all categories

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

  • Posts: 81604
  • Thank you received: 13082
  • MODERATOR
11 years 5 months ago #75623

Your code is wrong.

You want to have something like that:
<div id="hikashop_product_top_part" class="hikashop_product_top_part">

<?php
foreach($this->categories as $category){
?>
<h2>
<span><?php echo $category->category_name; ?>
</span></h2><br/>


<?php if($category->category_name=="Linea Esencial"){
echo '<hr class="linea">';
}elseif($category->category_name=="Linea Equilibrante"){
echo '<hr class="linea2">';
}elseif($category->category_name=="Linea Multivitaminas"){
echo '<hr class="linea3">';
}elseif($category->category_name=="Linea Multiefectos"){
echo '<hr class="linea4">';
}elseif($category->category_name="Linea de Barros"){
echo '<hr class="linea5">';
}elseif($category->category_name=="Linea Spa Corporal"){
echo '<hr class="linea6">';
}elseif($category->category_name="Manicura & Pedicura"){
echo '<hr class="linea7">';
}elseif($category->category_name=="Linea Spa Capilar"){
echo '<hr class="linea8">';
}?>

</div>

The following user(s) said Thank You: condorazul

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

  • Posts: 441
  • Thank you received: 24
11 years 5 months ago #75732

everything ok now thank you

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

  • Posts: 441
  • Thank you received: 24
11 years 5 months ago #77251

i have another issue with this, i´ve change shor_default.php view to do that and it works in product display, how can i make it to work also in product listing, my default is listing_image_title but i tried it there and it did not work, thanks

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

  • Posts: 26019
  • Thank you received: 4004
  • MODERATOR
11 years 5 months ago #77271

Hi,

In the product listing view, you do not have the $category variable like in the product show view.
But you can retrieve it.

$category_id = (int)trim($this->category_selected, '_');
$category = null;
if($category_id > 0) {
  $categoryClass = hikashop_get('class.category');
  $category = $categoryClass->get($category_id);
}
And you should have your category object !

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: 441
  • Thank you received: 24
11 years 5 months ago #77544

Jerome but if you go to the webpage
miraur.pingraf.es
in main page you have categories
if you click on any of those
the title of the category is displayed i product listing without doing anything.
what do i have to cahnge there?

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

  • Posts: 26019
  • Thank you received: 4004
  • MODERATOR
11 years 5 months ago #77604

Hi,

It is displayed because it's not a simple product listing.
It come from a category listing from your menu #102 (with id 102).

Exactly like our demo website.
If you go one the home page, you would see a menu at the bottom left.
You can click on the item "Peripherals" in the "Computing" section.
It points to : demo.hikashop.com/index.php?option=com_h...ls&Itemid=78&lang=en
As you can see in the URL, it is a category listing, it display products in this category and at the top of the listing, there is the name of the category.

That is the "category listing".

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: 441
  • Thank you received: 24
11 years 5 months ago #77675

so i should add my variable in category listing right?

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

  • Posts: 26019
  • Thank you received: 4004
  • MODERATOR
11 years 5 months ago #77794

Hi,

You have to edit the "category / listing" view.
At the beginning of the view, you would find the code which display the name of the category.

if($this->params->get($title) && JRequest::getVar('hikashop_front_end_main',0)){
	?>
	<<?php echo $titleType; ?>>
	<?php echo $this->params->get('page_title'); ?>
	</<?php echo $titleType; ?>>
	<?php
}

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: 441
  • Thank you received: 24
11 years 5 months ago #78025

Jerome i have to add this to generate the hr but i dont know where
<?php if($category->category_name=="LINEA ESENCIAL MIRAUR Dermocosmetics"){
echo '<hr class="linea">';
}elseif($category->category_name=="LINEA EQUILIBRANTE MIRAUR Dermocosmetics"){
echo '<hr class="linea2">';
}elseif($category->category_name=="LINEA MULTIVITAMINAS MIRAUR Dermocosmetics"){
echo '<hr class="linea3">';
}elseif($category->category_name=="LINEA MULTIEFECTOS MIRAUR Dermocosmetics"){
echo '<hr class="linea4">';
}elseif($category->category_name="LINEA DE BARROS MIRAUR Dermocosmetics"){
echo '<hr class="linea5">';
}elseif($category->category_name=="LINEA SPA CORPORAL MIRAUR Dermocosmetics"){
echo '<hr class="linea6">';
}elseif($category->category_name="MANICURA & PEDICURA MIRAUR Dermocosmetics"){
echo '<hr class="linea7">';
}elseif($category->category_name=="LINEA SPA CAPILAR MIRAUR Dermocosmetics"){
echo '<hr class="linea8">';
}?>

i added it here
f($this->params->get($title) && JRequest::getVar('hikashop_front_end_main',0)){
?>
<<?php echo $titleType; ?>>
<?php echo $this->params->get('page_title'); ?>
</<?php echo $titleType; ?>>
<?php if($category->category_name=="LINEA ESENCIAL MIRAUR Dermocosmetics"){
echo '<hr class="linea">';
}elseif($category->category_name=="LINEA EQUILIBRANTE MIRAUR Dermocosmetics"){
echo '<hr class="linea2">';
}elseif($category->category_name=="LINEA MULTIVITAMINAS MIRAUR Dermocosmetics"){
echo '<hr class="linea3">';
}elseif($category->category_name=="LINEA MULTIEFECTOS MIRAUR Dermocosmetics"){
echo '<hr class="linea4">';
}elseif($category->category_name="LINEA DE BARROS MIRAUR Dermocosmetics"){
echo '<hr class="linea5">';
}elseif($category->category_name=="LINEA SPA CORPORAL MIRAUR Dermocosmetics"){
echo '<hr class="linea6">';
}elseif($category->category_name="MANICURA & PEDICURA MIRAUR Dermocosmetics"){
echo '<hr class="linea7">';
}elseif($category->category_name=="LINEA SPA CAPILAR MIRAUR Dermocosmetics"){
echo '<hr class="linea8">';
}?>
<?php
but it always choose line 5 by default and does not display waht i want

Last edit: 11 years 5 months ago by condorazul.

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

  • Posts: 13201
  • Thank you received: 2322
11 years 5 months ago #78140

Hi,

Try with "$this->element->category_name" instead of "$category->category_name"

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

Time to create page: 0.099 seconds
Powered by Kunena Forum