Author Topic: "if" manufacturer id = 1  (Read 172 times)

marvays

  • Jr. Member
  • **
  • Posts: 122
    • http://marvays.cz
  • Skype Name: marvays
"if" manufacturer id = 1
« 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 :(

Code: [Select]
<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>

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 8433
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 2.6.22 & 3.2.14
Re: "if" manufacturer id = 1
« Reply #1 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?
GJC Web Design
VirtueMart and Joomla Developers - php developers http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

StefanSTS

  • Global Moderator
  • Jr. Member
  • *
  • Posts: 213
  • VirtueMart Version: VM 4.2 on Joomla 4.5
Re: "if" manufacturer id = 1
« Reply #2 on: November 08, 2018, 23:22:21 pm »
Maybe the / before the path /templates?

image got the right permissions?
--
Stefan Schumacher
www.jooglies.com - VirtueMart Invoice Layouts

PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10291
  • VirtueMart Version: 3+
Re: "if" manufacturer id = 1
« Reply #3 on: November 08, 2018, 23:39:59 pm »
on the product page

$this->product->virtuemart_manufacturer_id[0]
I do NOT do development work for hire.

marvays

  • Jr. Member
  • **
  • Posts: 122
    • http://marvays.cz
  • Skype Name: marvays
Re: "if" manufacturer id = 1
« Reply #4 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.
Code: [Select]
<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>


Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3466
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 &amp; 3.0.x.y
Re: "if" manufacturer id = 1
« Reply #5 on: November 10, 2018, 01:34:10 am »
Very strange code ?
To be sure your link is right use JURI:root(true)
Code: [Select]
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
Code: [Select]
if ((int)$this->product->virtuemart_manufacturer_id===1 ){
So the final code should be
Code: [Select]
<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