View Full Version : How can I Conditionally Display Custom Product Fields?
I'm using MM4.2 with OUI. I've created custom product fields that I'm calling in my custom product page. I'm trying to display these custom fields when necessary, and if left empty, to hide the field.
For example, I've created the following custom fields for my products: Size, Material, Shipping, Status. As I have over a thousand products in my store it will take a very long time to populate every field for every product, and in some cases it won't be necessary at all, so in those cases I would like the custom product page to skip these empty fields rather than display something like...
[product image]
Code: product 1223
Price: $12.99
Size:
Material:
Shipping:
Status:
I've been trying to configure my custom page using a "block" call, but I'm lost. The SIZE field either displays if the field is blank, or not at all, even with a populated field. Can someone please help???
%OUI%
%begin_length|g.OUI_Xproducts:SIZE%
Size:<B>%ACTION(XPFIELDS)%
%VAR(g.OUI_Xproducts:SIZE)%
</B><BR>
%end_notlength|g.OUI_Xproducts:SIZE%
klassic
07-31-07, 07:03 PM
Your %begin and %end tokens are different. You should have %end_length|g.OUI_Xproducts:SIZE%
Now I am not stating the syntax of these tokens are correct, but if you %begin_x% you need to %end_x%.
Your %begin and %end tokens are different. You should have %end_length|g.OUI_Xproducts:SIZE%
Now I am not stating the syntax of these tokens are correct, but if you %begin_x% you need to %end_x%.
I did them both, neither works.
%begin_notlength|g.OUI_Xproducts:SIZE%
Size:<B>%ACTION(XPFIELDS)%
%VAR(g.OUI_Xproducts:SIZE)%
</B><BR>
%end_notlength|g.OUI_Xproducts:SIZE%
If left empty this still shows the field "Size:" and it shows both the field "Size:" and the string I've entered "16 Inch Chain + 2 Inch Expansion Chain" if full. I need it to hide, "Size:".
%begin_length|g.OUI_Xproducts:SIZE%
Size:<B>%ACTION(XPFIELDS)%
%VAR(g.OUI_Xproducts:SIZE)%
</B><BR>
%end_length|g.OUI_Xproducts:SIZE%
This hides both the fields "Size:" and "16 Inch Chain + 2 Inch Expansion Chain" even if there is a string in the field.
klassic
07-31-07, 07:27 PM
I do not know if they are valid tokens that you are trying to use. Where did you find the tokens for %begin_length% %begin_notlength%? You need to look there to find out how to use the correctly. I am not familiar with those tokens.
I do not know if they are valid tokens that you are trying to use. Where did you find the tokens for %begin_length% %begin_notlength%? You need to look there to find out how to use the correctly. I am not familiar with those tokens.
That's why I've posted here. Because I can't figure it out, even using the manuals. I have OUI, so those are OUI conditionals that the interface offers from a drop down list.
:S
http://www.openui.org/oui_docs.php
Here are the token conditionals:
Token Conditionals
invshow
invsell
instock
outstock
lowstock
noweight
hasweight
inbasket
notinbasket
zeroprice
hasprice
login
notlogin
secure
notsecure
empty
notempty
screen|screencode
notscreen|screencode
length|variable
notlength|variable
Here are two images to show you in detail what I'm working with.
http://img127.imageshack.us/img127/2053/help1fk4.th.jpg (http://img127.imageshack.us/my.php?image=help1fk4.jpg)
The first shows that I can have these fields conditionally appear like I want using my default product template. However I can't find the code that this default template uses so that I can apply it to my custom template.
This image shows what happens if I apply my custom template, which shows the fields regardless of if they are empty or not.
http://img112.imageshack.us/img112/6981/help2tc3.th.jpg (http://img112.imageshack.us/my.php?image=help2tc3.jpg)
I figured it out! Well almost...
The issue was that I was trying to start the block before running the check on the length of the string. Now I'm trying to have it check the string before it runs the block but the only way I've been able to do this ends up expressing the value itself. Can anyone help explain how I can evaluate the value of the variable without actually posting it?
I need to change this:
%ACTION(XPFIELDS)%
%VAR(g.OUI_Xproducts:MATERIAL)%
to something that will evaluate but not express, any clues?
PS
Here's a sample of calling the variable before and how it posts:
Product Information
22Kt. Gold Plate Material: 22Kt. Gold Plate
vBulletin® v3.7.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.