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

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Locked
10010110
Translator
Translator
Posts: 224
Joined: Tue Jan 22, 2008 9:57 am

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

Post 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?
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

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

Post 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 *}
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
10010110
Translator
Translator
Posts: 224
Joined: Tue Jan 22, 2008 9:57 am

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

Post 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?
10010110
Translator
Translator
Posts: 224
Joined: Tue Jan 22, 2008 9:57 am

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

Post 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.
10010110
Translator
Translator
Posts: 224
Joined: Tue Jan 22, 2008 9:57 am

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

Post by 10010110 »

I’m still waiting for a solution/confirmation of this.
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

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

Post 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)?
10010110
Translator
Translator
Posts: 224
Joined: Tue Jan 22, 2008 9:57 am

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

Post 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.
Locked

Return to “Modules/Add-Ons”