I am customizing the category page so that my products are arranged in columns going 3 across. I looked at the freemarker manual at the list directive, and it cited a "item_index" variable. My intention was to use this variable and do some simple math to output rows and columns (tr's and td's)
<#list productCategoryMembers as productCategoryMember> <tr> <td> <h1> ${productCategoryMember_index} ${productCategoryMember_index % 3}</h1> <#if (($productCategoryMember_index % 3) = 1)>test </#if> </td> </tr> </#list> This errors out on the if test saying it it is not numerical. If I remove the "if" test, my numerical loop variable prints (for each product), and the mod 3 value. While this is a freemarker question, I am pretty certain that folks have made the same type of changes to their ofbiz code and have figured out how to do it. Thank you. Error on line 102, column 9 in component://order/webapp/ordermgr/entry/catalog/categorydetail-pp.ftl Expression $productCategoryMember_index is not numerical The problematic instruction: ---------- ==> if (($productCategoryMember_index % 3) = 1) [on line 102, column 2 in component://order/webapp/ordermgr/entry/catalog/categorydetail-pp.ftl] ---------- Java backtrace for programmers: ---------- freemarker.core.NonNumericalException: Error on line 102, column 9 in component://order/webapp/ordermgr/entry/catalog/categorydetail-pp.ftl Expression $productCategoryMember_index is not numerical at freemarker.core.ArithmeticExpression._getAsTemplateModel(ArithmeticExpression.java:96) at freemarker.core.Expression.getAsTemplateModel(Expression.java:89) at freemarker.core.ParentheticalExpression._getAsTemplateModel(ParentheticalExpression.java:75) at freemarker.core.Expression.getAsTemplateModel(Expression.java:89) at freemarker.core.ComparisonExpression.isTrue(ComparisonExpression.java:111) at freemarker.core.ParentheticalExpression.isTrue(ParentheticalExpression.java:66) at freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:77) |
I'd try == instead of =
Cheers, Tim -- Tim Ruppert HotWax Media http://www.hotwaxmedia.com o:801.649.6594 f:801.649.6595 On Oct 31, 2007, at 9:24 PM, Phillip Rhodes wrote: > I am customizing the category page so that my products are arranged > in columns going 3 across. I looked at the freemarker manual at the > list directive, and it cited a "item_index" variable. My intention > was to use this variable and do some simple math to output rows and > columns (tr's and td's) > > <#list productCategoryMembers as productCategoryMember> > <tr> > <td> > <h1> ${productCategoryMember_index} $ > {productCategoryMember_index % 3}</h1> > <#if (($productCategoryMember_index % 3) = 1)>test </#if> > </td> > </tr> > </#list> > > > This errors out on the if test saying it it is not numerical. > If I remove the "if" test, my numerical loop variable prints (for > each product), and the mod 3 value. > > While this is a freemarker question, I am pretty certain that folks > have made the same type of changes to their ofbiz code and have > figured out how to do it. > > Thank you. > > Error on line 102, column 9 in component://order/webapp/ordermgr/ > entry/catalog/categorydetail-pp.ftl Expression > $productCategoryMember_index is not numerical The problematic > instruction: ---------- ==> if (($productCategoryMember_index % 3) = > 1) [on line 102, column 2 in component://order/webapp/ordermgr/entry/ > catalog/categorydetail-pp.ftl] ---------- Java backtrace for > programmers: ---------- freemarker.core.NonNumericalException: Error > on line 102, column 9 in component://order/webapp/ordermgr/entry/ > catalog/categorydetail-pp.ftl Expression > $productCategoryMember_index is not numerical at > freemarker > .core > .ArithmeticExpression._getAsTemplateModel(ArithmeticExpression.java: > 96) at freemarker.core.Expression.getAsTemplateModel(Expression.java: > 89) at > freemarker > .core > .ParentheticalExpression > ._getAsTemplateModel(ParentheticalExpression.java:75) at > freemarker.core.Expression.getAsTemplateModel(Expression.java:89) at > freemarker > .core.ComparisonExpression.isTrue(ComparisonExpression.java:111) at > freemarker > .core.ParentheticalExpression.isTrue(ParentheticalExpression.java: > 66) at freemarker.core.ConditionalBlock.accept(ConditionalBlock.java: > 77) > > > smime.p7s (3K) Download Attachment |
Thanks, that was part of the problem. As a java developer, I did initially try that, but was still getting the error.
I did have to use == instead of = I also had to drop the $ from the variable name. Once I did this, I got my columns of products. Thanks! ----- Original Message ----- From: "Tim Ruppert" <[hidden email]> To: [hidden email] Sent: Wednesday, October 31, 2007 11:45:52 PM (GMT-0500) America/New_York Subject: Re: freemarker NonNumericalException error problem I'd try == instead of = Cheers, Tim -- Tim Ruppert HotWax Media http://www.hotwaxmedia.com o:801.649.6594 f:801.649.6595 On Oct 31, 2007, at 9:24 PM, Phillip Rhodes wrote: > I am customizing the category page so that my products are arranged > in columns going 3 across. I looked at the freemarker manual at the > list directive, and it cited a "item_index" variable. My intention > was to use this variable and do some simple math to output rows and > columns (tr's and td's) > > <#list productCategoryMembers as productCategoryMember> > <tr> > <td> > <h1> ${productCategoryMember_index} $ > {productCategoryMember_index % 3}</h1> > <#if (($productCategoryMember_index % 3) = 1)>test </#if> > </td> > </tr> > </#list> > > > This errors out on the if test saying it it is not numerical. > If I remove the "if" test, my numerical loop variable prints (for > each product), and the mod 3 value. > > While this is a freemarker question, I am pretty certain that folks > have made the same type of changes to their ofbiz code and have > figured out how to do it. > > Thank you. > > Error on line 102, column 9 in component://order/webapp/ordermgr/ > entry/catalog/categorydetail-pp.ftl Expression > $productCategoryMember_index is not numerical The problematic > instruction: ---------- ==> if (($productCategoryMember_index % 3) = > 1) [on line 102, column 2 in component://order/webapp/ordermgr/entry/ > catalog/categorydetail-pp.ftl] ---------- Java backtrace for > programmers: ---------- freemarker.core.NonNumericalException: Error > on line 102, column 9 in component://order/webapp/ordermgr/entry/ > catalog/categorydetail-pp.ftl Expression > $productCategoryMember_index is not numerical at > freemarker > .core > .ArithmeticExpression._getAsTemplateModel(ArithmeticExpression.java: > 96) at freemarker.core.Expression.getAsTemplateModel(Expression.java: > 89) at > freemarker > .core > .ParentheticalExpression > ._getAsTemplateModel(ParentheticalExpression.java:75) at > freemarker.core.Expression.getAsTemplateModel(Expression.java:89) at > freemarker > .core.ComparisonExpression.isTrue(ComparisonExpression.java:111) at > freemarker > .core.ParentheticalExpression.isTrue(ParentheticalExpression.java: > 66) at freemarker.core.ConditionalBlock.accept(ConditionalBlock.java: > 77) > > > |
Free forum by Nabble | Edit this page |