nVelocity question
Posted: Mon Jan 05, 2009 3:40 pm
I am trying to use the RelatedProducts collection on my products page in order to implement suggested selling (when we would rather have a customer order something other than what they are currently on (for shipping reasons)). My question is this: Can I use only the first item in the collection rather than loop through each of them? Here's what I have tried...
$Product.RelatedProducts[0].ChildProduct.Name
with no luck. If, however, I use...
#foreach ($relatedproduct in $Product.RelatedProducts)
$relatedproduct.ChildProduct.Name
#end
...I get the desired outcome. The problem, however, is that I may have more than one product, and eventually I am going to be including table elements that will be all screwed up if the loop executes more than one time. I have tried various forms of the variable with brackets with no luck (ie, ${{Product.RelatedProducts[0]}.ChildProduct.Name})
I know I could complete this (and probably will have to eventually) with a conlib control, but, I wanted to figure out why specifying the specific item with brackets causes the nVelocity to stop working.
Any help would be appreciated.
Scott
Scott
$Product.RelatedProducts[0].ChildProduct.Name
with no luck. If, however, I use...
#foreach ($relatedproduct in $Product.RelatedProducts)
$relatedproduct.ChildProduct.Name
#end
...I get the desired outcome. The problem, however, is that I may have more than one product, and eventually I am going to be including table elements that will be all screwed up if the loop executes more than one time. I have tried various forms of the variable with brackets with no luck (ie, ${{Product.RelatedProducts[0]}.ChildProduct.Name})
I know I could complete this (and probably will have to eventually) with a conlib control, but, I wanted to figure out why specifying the specific item with brackets causes the nVelocity to stop working.
Any help would be appreciated.
Scott
Scott