Author Topic: GTIN layout question  (Read 194 times)

Peter Möller

  • Beginner
  • *
  • Posts: 6
  • A beginner
GTIN layout question
« on: November 21, 2021, 22:13:24 pm »
A Virtuemart Newbee question ;-)

I was searching in the forum howto output gtin, learned best way is a template override. Just gave it a try with product details.

It worked fine with this code:
Code: [Select]
<?php // Product GTIN/ISBN   ?>
    <?php 
if (!empty(
$this->product->product_gtin)) {
        echo 
'<div class="product-fields">';
echo '<div class="product-field product-field-type-S">';
echo '<span class="product-fields-title-wrapper"><span class="product-fields-title"><strong>ISBN</strong></span></span>';
echo '<div class="product-field-display">' .  $this->product->product_gtin '</div></div>';
        echo 
'</div>';
    }
?>

<?php // Product GTIN/ISBN END ?>

I wonder, if those class details could be handled by virtuemart itself and I just would call something like
Code: [Select]
shopFunctionsF::renderVmSubLayout()
Is there a standard layout or sublayout, that I may use?

Thx alot in advance for suggestions and hints :-)

pinochico

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 1235
    • MiniJoomla
  • Skype Name: support-easysoftware
  • VirtueMart Version: 3
Re: GTIN layout question
« Reply #1 on: November 22, 2021, 01:20:44 am »
Why complicate and complicate code?

Of course you can use sublayout, but who would do it because of one unused field?

If anyone needed it, another field could have been long overdue and you would have 20 sublayouts at once - do you really want me not to know them either?
www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds from products, orders and database table
Virtuemart Email Manager - customs email templates

Peter Möller

  • Beginner
  • *
  • Posts: 6
  • A beginner
Re: GTIN layout question
« Reply #2 on: November 22, 2021, 18:52:13 pm »
@pinochico: Thx for your answer :-). I see the point and you are right . I should have asked more precisely.

Since I have a couple of custom fields, I would like the gtin layout to be the same like the custom fields. There is a existing call of type

Code: [Select]
echo shopFunctionsF::renderVmSubLayout('customfields',...);
Why would i like to do so?

If there is a change in the SubLayout of custom fields, then my private code from the first post would get different from the SubLayout.

Please take into account, that this is my first virtuemart project and I just try to do it in a clean way ;-)

[UPD] In other words: May I use a function, where I name the field, that I want to display and the format to use, for instance 'custom field'?

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4516
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: GTIN layout question
« Reply #3 on: November 24, 2021, 16:09:43 pm »
renderVmSubLayout is to reuse the same code for different cases.
If it's only to render a single field, that's not appropriate.

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 10291
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.6.8
Re: GTIN layout question
« Reply #4 on: November 24, 2021, 16:39:39 pm »
Quote
In other words: May I use a function, where I name the field, that I want to display and the format to use, for instance 'custom field'?

you could of course ignore the GTIN field and just make a text custom field named ISBN ... many ways to skin a cat ..  this is the advantage of VM .. so many ways to make it bespoke..  :)
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