News:

Support the VirtueMart project and become a member

Main Menu

GTIN layout question

Started by Peter Möller, November 21, 2021, 22:13:24 PM

Previous topic - Next topic

Peter Möller

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:
<?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
shopFunctionsF::renderVmSubLayout()

Is there a standard layout or sublayout, that I may use?

Thx alot in advance for suggestions and hints :-)

pinochico

#1
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 for FB, GMC,.. from products, categories, orders, users, articles, acymailing subscribers and database table
Virtuemart Email Manager - customs email templates
Import products for Virtuemart - from CSV and XML
Rich Snippets - Google Structured Data
VirtueMart Products Extended - Slider with products, show Others bought, Products by CF ID and others filtering products

Peter Möller

#2
@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

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

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

QuoteIn 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 https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 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
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation