News:

Looking for documentation? Take a look on our wiki

Main Menu

Insert Custom Field to Modules VirtueMart Products

Started by baoquocmt159, September 13, 2013, 03:45:39 AM

Previous topic - Next topic

baoquocmt159

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

Maxim Pishnyak

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
You can support Community by voting for Project on the JED
https://extensions.joomla.org/extension/virtuemart/#reviews
Join us at
https://twitter.com/virtuemart

baoquocmt159

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 !