VirtueMart Forum

VirtueMart 2 + 3 + 4 => Product creation => Topic started by: Елeна on May 12, 2020, 07:11:05 AM

Title: label on the category page
Post by: Елeна on May 12, 2020, 07:11:05 AM
Hello.
VirtueMart 3.6.10 / Joomla! 3.9.12 / protostar / site

To display the label "new" "sale" on the category page I use a Custom Field 'Image'
To output to a file \templates\protostar\html\com_virtuemart\sublayouts\products.php
code
  // Show Products ?>
<div class="product vm-col<?php echo ' vm-col-' $products_per_row $show_vertical_separator ?>">
<div class="spacer product-container">
<div class="vm-product-media-container">
               <?php echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$product,'position'=>'yarl'));?>
               <?php echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$product,'position'=>'yarl1'));?>
               <?php echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$product,'position'=>'yarl2'));?>
<a title="<?php echo $product->product_name ?>" href="<?php echo $product->link.$ItemidStr?>">
<?php
echo $product->images[0]->displayMediaThumb('class="browseProductImage"'false);
?>

</a>

</div>


It works, but the shortcuts are above the main image. screen (https://drive.google.com/open?id=1YEZiK-4JPsZuR5rNcCx6cPHfpE6hAq6l)
Labels should be next to the main image.
Title: Re: label on the category page
Post by: GJC Web Design on May 12, 2020, 08:59:12 AM
surround the labels with an absolute positioned div and make .product-container position relative

then u can position the labels where ever u want
Title: Re: label on the category page
Post by: Елeна on May 12, 2020, 09:26:26 AM
Thank you for participating.


Thank you very much for your help!
The method works perfectly!
Title: Re: label on the category page
Post by: pinochico on May 12, 2020, 11:34:32 AM
New is internal function Virtuemart for every product.
Sale is internal function Virtuemart on every product detail in admin (checkbox).

Then you don't need create customfield and forcing administrators to fill in additional information is unproductive.
Better, develop correctly following this information.

Or you can use one of the existing plugins to create labels.
Title: Re: label on the category page
Post by: Елeна on May 12, 2020, 12:36:35 PM
Please, where in the creation of the product there is a shortcut output to the category page, without using the plugin.
There are many products in the category and only two new ones. One of them is light, the other is heavy.
the label on the product: "new" "heavy"
the label on the product: "new "" light"
Thank
Title: Re: label on the category page
Post by: pinochico on May 12, 2020, 14:59:25 PM
QuotePlease, where in the creation of the product there is a shortcut output to the category page, without using the plugin.

New == date of creation product is saved in DB. Then if you don't use plugin, then must call DB and select all product which is new (setup how long time is for new :)
This select  you must save as value and then create if else for every product on category view and after yes, then put label to sublayout product.