Page 1 of 1

How is the “fieldval” parameter in Products module used?

Posted: Wed Feb 04, 2015 9:18 am
by 10010110
I’m using the Products module to show a list (and details) of products, and I’m using the CompanyDirectory module because it provides a custom field in the Products module (called “company ID”) so that I can associate and show the company name for each product. I’m also listing all companies on a page and I want to show the products each company is associated with, and this is the reason I’m posting here.

So, I’m thinking of embedding the Products module call inside the CompanyDirectory template and filter the products by the company ID using the “fieldval” parameter. But how is this parameter actually used? The module help only says:
fieldval="" - […] this parameter allows specifying a field value to limit results by. In the default value these special values are accepted: "::null::" "::notnull::" and wildcard chars (* or %).
How do I use the value of the company ID field to filter the Products?

Re: How is the “fieldval” parameter in Products module used?

Posted: Wed Feb 04, 2015 5:01 pm
by calguy1000
it's used in conjunction with the 'field' parameter.

i.e: {Products field='foo' fieldval='::notnull::'} {* generate a summary view of all products that have some value for the foo field *}
{Products field='foo' fieldval='*bar*'} {* generate a summary view of all products that have the substring bar for the foo field *}

Re: How is the “fieldval” parameter in Products module used?

Posted: Fri Feb 06, 2015 8:14 am
by 10010110
Thanks for your reply calguy1000. According to the module help the “field” parameter can only be used in the fieldlist and the ajax_propval actions. I’m trying to view the product summary list (i. e. default action) inside the CompanyDirectory detail template. Therefore I placed the following module call in the template:

Code: Select all

{Products field="my_custom_fieldname" fieldval=$entry->id}
This doesn’t seem to work, it shows all products, even if the field isn’t set (or set to a different company ID); if I change the action to “fieldlist” then it shows a link “Products Matching n(n)” where n is the number of matching products, which is apparently exactly what it’s supposed to do, according to the module help. But the help is unprecise because it says:
field="" - Used in the fieldlist and the ajax_propval actions. […]
fieldval="" - Used in the default and ajax_propval actions […]
Am I misunderstanding something here? How do I display the product summary view/template inside the company detail template, with only showing the products matching the current company ID?

Re: How is the “fieldval” parameter in Products module used?

Posted: Mon Feb 09, 2015 10:10 pm
by 10010110
I really need help with this one. :( How can I list all products associated with a company on the company detail page? I can’t move on with the project until this is solved which kinda sucks.

Re: How is the “fieldval” parameter in Products module used?

Posted: Mon Feb 16, 2015 10:28 pm
by 10010110
I’m still waiting for a solution/confirmation of this.

Re: How is the “fieldval” parameter in Products module used?

Posted: Tue Feb 17, 2015 9:10 am
by velden
I think we already discussed this (in #cms). It seems that you can't use the fieldval parameter for your goal.

Consider using categories or think of a custom UDT to do some fancy stuff (like database query or maybe Products has some API that can be used, I don't know).

If you really have no other option why not getting all products and filtering those in foreach loop (very inefficient of course)?

Re: How is the “fieldval” parameter in Products module used?

Posted: Tue Feb 17, 2015 3:16 pm
by 10010110
velden wrote:I think we already discussed this (in #cms).
Yes, we did but I was kinda hoping for a comment from calguy since he probably knows in detail what the module has to offer and/or why not.