VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: marvays on November 08, 2018, 21:34:25 PM

Title: "if" manufacturer id = 1
Post by: marvays on November 08, 2018, 21:34:25 PM
Hi again.
Now I trying write custom code to product detail page. i need show one image, if manufacturer have id 1.
But, my code not work :(


<div class="VyrobenoCR">
<?php // Czechia flag
                if ($this->product->virtuemart_manufacturer_id==){ 
        echo '<img src="/templates/astroid_template_zero/html/com_virtuemart/assets/images/availability/flag-cr.png" />';
}?>

</div>
Title: Re: "if" manufacturer id = 1
Post by: GJC Web Design on November 08, 2018, 23:15:46 PM
is your var correct and what is  its value when u echo it out? 
img path correct?
Title: Re: "if" manufacturer id = 1
Post by: StefanSTS on November 08, 2018, 23:22:21 PM
Maybe the / before the path /templates?

image got the right permissions?
Title: Re: "if" manufacturer id = 1
Post by: PRO on November 08, 2018, 23:39:59 PM
on the product page

$this->product->virtuemart_manufacturer_id[0]
Title: Re: "if" manufacturer id = 1
Post by: marvays on November 09, 2018, 06:30:53 AM
My friend of the Czech community VM advised me. I post here if someone liked it and wanted to use it.

<div class="VyrobenoCR">
<?php // Vyrobeno v ČR
        
$pole $this->product->virtuemart_manufacturer_id;
        
$klic array_search('1'$pole);
          if (is_numeric($klic)){ 
        echo '<img src="/templates/astroid_template_zero/html/com_virtuemart/assets/images/availability/vlajka-cr.png" />';
}?>

        </div>


Title: Re: "if" manufacturer id = 1
Post by: Studio 42 on November 10, 2018, 01:34:10 AM
Very strange code ?
To be sure your link is right use JURI:root(true)
echo '<img src="'.JURI:root(true).'/templates/astroid_template_zero/html/com_virtuemart/assets/images/availability/vlajka-cr.png" />';
for $this->product->virtuemart_manufacturer_id convert to int to be sure
if ((int)$this->product->virtuemart_manufacturer_id===1 ){

So the final code should be
<div class="VyrobenoCR">
<?php 
         if ((int)
$this->product->virtuemart_manufacturer_id===){
        echo '<img src="'.JURI:root(true).'/templates/astroid_template_zero/html/com_virtuemart/assets/images/availability/vlajka-cr.png" />';
?>

        </div>

Note that i dont understand why you use the folder templates/astroid_template_zero/html/com_virtuemart/assets/images/availability
And not a shorter one.
templates/astroid_template_zero/images/virtuemart/manufacturer/vlajka-cr.png