News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

how to echo only needed custom fields ?

Started by 2dmaster, June 23, 2018, 22:56:22 PM

Previous topic - Next topic

2dmaster

I need to print only like 1,3,5 values of foreach. I have foreach in my template (joomla - virtuemart)

foreach($product->customfields as $field){
    echo $field->virtuemart_custom_id;
    echo $field->custom_title;
    echo $field->customfield_value;
    echo "<br>";
}
Why this code in foreach not works ? ↓↓↓

if($field->virtuemart_custom_id == 1) {echo "get 1<br>";}
if($field->virtuemart_custom_id == 3) {echo "get 3";}

How get only 1,3,5,8,20 $customfield ?? in foreach.

Jörgen

Try this:

print_r( $field);

To see what $field holds

Jörgen @ Kreativ Fotografi
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

Jörgen

You will have to put some effort into this yourself. Try my suggestion and examine the output. Then You will see what to echo or print.

regards

Jörgen @ Kreativ Fotografi
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

Studio 42

Why not using a new position "my-position"
And render it with :
   echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$this->product,'position'=>'my-position'));
Free XML sitemap generator [url="http://shop.st42.fr/en/catalog/products/virtuemart-2-sitemap.htm"]http://shop.st42.fr/en/catalog/products/virtuemart-2-sitemap.htm[/url]  , Free Unused Image cleaner [url="http://shop.st42.fr/en/products/virtuemart-media-folder-clear.htm"]http://shop.st42.fr/en/products/virtuemart-media-folder-clear.htm[/url]
Language Switch in product & category [url="http://shop.st42.fr/en/categories-tools/multi-language-for-virtuemart.htm"]http://shop.st42.fr/en/categories-tools/multi-language-for-virtuemart.htm[/url]
More extentions [url="http://shop.st42.fr/en/"]http://shop.st42.fr/en/[/url]