News:

Looking for documentation? Take a look on our wiki

Main Menu

category show customfields value

Started by AnthonyWang, March 28, 2016, 20:08:42 PM

Previous topic - Next topic

AnthonyWang

is there any solution,can get customfield values on category page not products,
for example,
just like customer text input plugin,fefault Size of input  is 10.
i want "10" show on category or categories page,


i tried
$customPlugin['oooooo'];
get NULL
$customfields['oooooo']['oooooooo'];
get NULL
$customfields->ooooooo;
get NULL

it's very important to me,because all values is for food ingredients,i want show it all on category page
hope someone can help,many thanks!
Currently using :
Joomla 3.6.5 / Virtuemart 3.2.1 / PHP 5.5.9-1ubuntu4.17

Studio 42

If you check on category page, all product customfields are under  the $product itself, but this depend sometime the template overide too.
So in the loop of products you can show all using
var_dump($product->customfieldsSorted);

AnthonyWang

i did tried this code yesterday but in wrong document,now i found the problem,many thanks!
Currently using :
Joomla 3.6.5 / Virtuemart 3.2.1 / PHP 5.5.9-1ubuntu4.17

AnthonyWang

is this possible work on category page (category/default.php)?
Currently using :
Joomla 3.6.5 / Virtuemart 3.2.1 / PHP 5.5.9-1ubuntu4.17

Studio 42

No, it not work, because you have to loop.
eg.
foreach($this->products as $product)  var_dump($product->customfieldsSorted);
TO get all customfields, i think $product->customfields should work in vm 3.0.12 too.

Ghost

#5
Just include customfields sublayout in products sublayout, inside product loop:

<?php echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$product,'position'=>'normal'));?>

This is if you want to show all custom fields by default. If you need only a few, you can instead assign them to an existent position (e.g. addtocart) and they will show up in that position. Or you can keep this code but change the position to something else so only custom fields with that position appear.

AnthonyWang

Thanks Studio42,
but echo value in products loop,is not a good solution,
i want values can show on category page,
anyway thanks for your info.
Currently using :
Joomla 3.6.5 / Virtuemart 3.2.1 / PHP 5.5.9-1ubuntu4.17

Studio 42

This depend your need, if you need to get some customfields, then you can get it using this loop.
The dump, is only for test.