VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: nebojsa on August 28, 2020, 10:53:01 AM

Title: Choosing custom fields to show on category page SOLVED
Post by: nebojsa on August 28, 2020, 10:53:01 AM
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
Title: Re: Choosing custom fields to show on category page
Post by: nebojsa on August 30, 2020, 17:33:30 PM
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));?>
Title: Re: Choosing custom fields to show on category page SOLVED
Post by: pinochico on August 30, 2020, 19:52:31 PM
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...
Title: Re: Choosing custom fields to show on category page SOLVED
Post by: nebojsa on October 25, 2020, 10:59:14 AM
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.
Title: Re: Choosing custom fields to show on category page SOLVED
Post by: pinochico on October 25, 2020, 11:51:31 AM
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.
Title: Re: Choosing custom fields to show on category page SOLVED
Post by: nebojsa on October 25, 2020, 15:40:13 PM
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.
Title: Re: Choosing custom fields to show on category page SOLVED
Post by: pinochico on October 25, 2020, 17:39:43 PM
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 :)
Title: Re: Choosing custom fields to show on category page SOLVED
Post by: nebojsa on November 03, 2020, 23:41:41 PM
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.
Title: Re: Choosing custom fields to show on category page SOLVED
Post by: loxlay on June 22, 2023, 18:01:19 PM
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
Title: Re: Choosing custom fields to show on category page SOLVED
Post by: Studio 42 on June 26, 2023, 10:46:09 AM
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.
Title: Re: Choosing custom fields to show on category page SOLVED
Post by: loxlay on June 26, 2023, 12:22:54 PM
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.
Title: Re: Choosing custom fields to show on category page SOLVED
Post by: loxlay on June 30, 2023, 12:50:06 PM
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));
Title: Re: Choosing custom fields to show on category page SOLVED
Post by: Studio 42 on June 30, 2023, 13:09:57 PM
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
Title: Re: Choosing custom fields to show on category page SOLVED
Post by: 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
Title: Re: Choosing custom fields to show on category page SOLVED
Post by: loxlay on July 07, 2023, 10:40:11 AM
This is the solution :)
Thank you :D
Title: Re: Choosing custom fields to show on category page SOLVED
Post by: jenkinhill on July 07, 2023, 11:54:57 AM
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?
Title: Re: Choosing custom fields to show on category page SOLVED
Post by: GJC Web Design on July 07, 2023, 15:24:53 PM
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 )
Title: Re: Choosing custom fields to show on category page SOLVED
Post by: jenkinhill on July 07, 2023, 16:00:01 PM
I get it. I never played much with custom fields.