VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: baoquocmt159 on September 13, 2013, 03:45:39 AM

Title: Insert Custom Field to Modules VirtueMart Products
Post by: baoquocmt159 on September 13, 2013, 03:45:39 AM
Hi all, I'm use Joomla 2.5 and VM 2.0

I wana insert Custom Field to Module VirtueMart Products now. I use code :
if (!empty($this->product->customfieldsSorted['ontop'])) {
$this->position = 'ontop';
echo $this->loadTemplate('customfields');
    } // Product Custom ontop end
    ?>


insert to file default.php. But it happen error : Fatal error: Using $this when not in object context in C:\xampp\htdocs\demo\modules\mod_virtuemart_product\tmpl\default.php on line 34

Help me, please !

Mod edit:  impatient bump message removed. This is not a chat room.  http://forum.virtuemart.net/index.php?board=114.0
Title: Re: Insert Custom Field to Modules VirtueMart Products
Post by: Maxim Pishnyak on September 13, 2013, 09:34:08 AM
You need to read some sticked threads in Template forum section. You could find some useful examples there.
$this->product is for product pages
in other cases $product-> construction could be used
Title: Re: Insert Custom Field to Modules VirtueMart Products
Post by: baoquocmt159 on September 14, 2013, 03:50:52 AM
Thank mod moved topic !

But i unresolved :( .I try use code :


$custom_title = null;
foreach ($products->customfieldsSorted['ontop'] as $field) {
if ( $field->is_hidden ) //OSP http://forum.virtuemart.net/index.php?topic=99320.0
continue;
if ($field->display) {
?><div class="product-field product-field-type-<?php echo $field->field_type ?>">
<?php if ($field->custom_title != $custom_title) { ?>
<span class="product-fields-title" ><?php echo JText::_($field->custom_title); ?></span>
<?php
if ($field->custom_tip)
echo JHTML::tooltip($field->custom_tipJText::_($field->custom_title), 'tooltip.png');
}
?>

<span class="product-field-display"><?php echo $field->display ?></span>
<span class="product-field-desc"><?php echo jText::_($field->custom_field_desc?></span>
</div>
<?php
$custom_title $field->custom_title;
}
}


It's error below :


Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\demo\modules\mod_virtuemart_product\tmpl\default.php on line 86


Help me !
Title: Re: Insert Custom Field to Modules VirtueMart Products
Post by: Maxim Pishnyak on September 14, 2013, 09:31:58 AM
Try these
http://forum.virtuemart.net/index.php?topic=99225.msg344246#msg344246
https://forum.virtuemart.net/index.php?topic=100191
Title: Re: Insert Custom Field to Modules VirtueMart Products
Post by: Maxim Pishnyak on September 14, 2013, 09:32:46 AM
Quote from: baoquocmt159 on September 14, 2013, 03:50:52 AM
But i unresolved :(
So do you have custom fields or you don't?
Try these
http://forum.virtuemart.net/index.php?topic=99225.msg344246#msg344246
https://forum.virtuemart.net/index.php?topic=100191