Hi everyone,
Is there a way to show specific custom fields on category view?
I would like to show related products on category view page.
In previous version of Virtuemart I had to add separate function in shop.browse.php and call that function from category view.
Virtuemart has changed a lot since first versions and I cannot find appropriate files for various functions.
So far I was only able to find how to display addtocart with customfields on category page.
<?php echo shopFunctionsF::renderVmSubLayout('addtocart',array('product'=>$product,'rowHeights'=>$rowsHeight[$row], 'position' => array('ontop', 'addtocart'))); ?>
Thank you in advance.
Joomla! 3.9.20
VirtueMart 3.8.4 10335
Using commercial theme template
Still more questions than answers on this forum :(
In case anyone need it, rendering functions for category page is different than on product details page:
So if you want to show related products on category page, here it is:
<?php echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$product, 'position'=>'related_products', 'class'=> 'product-related-products','customTitle' => true));?>
Related products are set for each product separately.
This is the right idea to display related products correctly == is always related to the product and not to the whole category.
Thank you for the information, but I will not use this solution.
And if the owner of the e-shop convinced me that he wanted it (but not really, because the owner of the e-shop does not understand how to make an e-shop), then I would use the Related Products Module (which show products by specific customfiiled) for the category and not this solution.
Module with JS Slideshow, maybe a couple of modules inside tabs...
What module exactly you are talking about?
I am a shop owner and I have a product which use spare part which I would like to show on category page along with products. For example - a grinding machines which uses grinding stones - and I want buyers to see grinding stones machine use so they can find and replace easily.
For this solution you don't need https://www.minijoomla.org/extensions/virtuemart-extensions/related-products-extended-for-virtuemart (https://www.minijoomla.org/extensions/virtuemart-extensions/related-products-extended-for-virtuemart), but you can set up a separate category for grinding stones and use core module VirtueMart Product and set up this category and put this module bottom or above products from category a grinding machine.
But if you want, you can use Related Products Extended for Virtuemart for other reasons.
I still don't understand what do you see wrong in my solution?
If you make separate module position then it will not look easy and simple for the visitors.
http://www.gravex.rs/en/naslovna/1-pecati-i-stambilji/2-standardni (http://www.gravex.rs/en/naslovna/1-pecati-i-stambilji/2-standardni).
Check out my old website and see what I mean.
Your solutions are perfect, thanks.
If you have 20 products in category and for every product have 20 related products, then you show 400 products, isn't right?
But I use even so module, better for me, admin and all :)
If I want to show 400 related products on category page that's my personal thing.
On the other hand ...
Modules, modules, modules ... and after some time those modules start loosing support, it turns out they are full of security issues and I am left all alone to deal with it.
No thanks to more modules on my website, sorry.
Hi,
is there a solution for Joomla 4 and VirtueMart 4?
The code mentioned here unfortunately no longer works. The sub layouts have also been abolished.
Does anyone have an idea?
Thanks loxlay
Are you sure that the code not work ?
You have an option in VM config to disable custom fields in Category view, please verify your settings.
Hi,
yes I'm sure. The fields are active in vm config. It is displayed on product detail page, but not on category page.
In Joomla 3 it worked with this command using template overrides but not with Joomla 4.
Hi,
which file is the correct one?
I tried this two:
/components/com_virtuemart/views/category/tmpl/default.php
/components/com_virtuemart/sublayouts/products.php
Using this code:
echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$product, 'position'=>'related_products', 'class'=> 'product-related-products','customTitle' => true));
You should not edit the virtuemart file directly but use a template override
copy original com_virtuemart/sublayouts/customfields.php
in
templates/YOURTEMPLATE/html/com_virtuemart/sublayouts/customfields.php
calling shopFunctionsF::renderVmSubLayout('customfields' .... is for the sublayout customfields
In VM4 to get custom fields to show up on a cat display of the product you have to check "Cart Attribute"
I have no idea why this changed in VM4
This is the solution :)
Thank you :D
Quote from: GJC Web Design on June 30, 2023, 15:26:44 PM
In VM4 to get custom fields to show up on a cat display of the product you have to check "Cart Attribute"
I have no idea why this changed in VM4
Surely customs have to be cart attributes to enable selection for adding to cart from browse view. Logical?
Didn't used to be for VM3..
I often used customfields as a function to do something that would only occur if attached to the product and these all disappeared from the category views on VM4 upgrades and they had to have their "cart attribute" checked --
which can be a pain as they then appear as labels in the cart product where as they are only intended as pure functional customs ( background functions etc )
I get it. I never played much with custom fields.