News:

Looking for documentation? Take a look on our wiki

Main Menu

Category - echo icons images

Started by gpessoa, April 16, 2020, 23:02:43 PM

Previous topic - Next topic

gpessoa

Hi ppl,
I want to echo a few different icons on categories page called from product_mpn BO;
The idea is if I put in MPN any number >1 it should echo the correspondent image
If MPN is 10 it should echo <img src="/images/icons/10.png">
If MPN is 11 it should echo <img src="/images/icons/11.png">

But it only echo <img src="/images/icons/.png">   
(doesn't get the mpn content)

<?php if ($product->product_mpn >1) { ?>
         <div class="mpn-promo"> <?php echo '<img src="images/icons/'$product_mpn .'.png">'?></div>
          <?php    }?>


Thanks in advance
gpessoa

J3.9.12
VM3.4.2
J 4.4.4; VM 4.2.6; PHP 8.3.6

Jörgen

maybe you should compare with correct type ?
$product->product_mpn >"1"

try also
echo '<pre>';
print_r($product);
echo '</pre>';


Jörgen @ Kreativ Fotografi
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

Studio 42

Not
echo '<img src="images/icons/'. $product_mpn .'.png">'
but
echo '<img src="images/icons/'. $product->product_mpn .'.png">

gpessoa

Hi again,
Thanks Studio 42, you make my day!

Is there a possibility to create an interval like:
<?php if ($product->product_mpn >1) echo promo1 div class (Works ok!)

something like this:
<?php if ($product->product_mpn >1 and <100) echo promo1 div class
<?php if ($product->product_mpn >101 and <200) echo promo2 div class
<?php if ($product->product_mpn >201 and <300) echo promo3 div class

Thanks in advance
gpessoa

J3.9.12
VM3.4.2
J 4.4.4; VM 4.2.6; PHP 8.3.6

Jörgen

Try something like this

<?php
if (($product->product_mpn '001') and ($product->product_mpn '100')) {
  echo 
'Yourstuff 1';
} else if ((
$product->product_mpn >'101') and ($product->product_mpn '200')) {
  echo 
'Yourstuff 2';
} else if ((
$product->product_mpn '201') and ($product->product_mpn '300')) {
  echo 
'Yourstuff 3';
}
?>



Jörgen @ Kreativ Fotografi
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.