Store UI, layout, design, look and feel; Discussion on the customer facing pages of your online store. Cascading Style Sheets, Themes, Scriptlets, NVelocity and the components in the ConLib directory.
-
Will
- Captain (CAPT)
- Posts: 263
- Joined: Fri Oct 05, 2007 8:02 am
Post
by Will » Thu Oct 25, 2007 3:26 pm
On the product page, I want to display all of the categories a particular product belongs to.
I see there's a Product.Categories property. I can loop through it:
Code: Select all
#foreach($cf in $Product.Categories)
#end
But I can't figure out the syntax to retrieve the name of each category as I loop through them. Having difficulty making sense of the rough API guide (as a non-programmer).
It should probably look something like:
Code: Select all
#foreach($cf in $Product.Categories)
$cf.something
#end
Just need to know the ".something".
Thanks.
-
Logan Rhodehamel
- Developer
- Posts: 4116
- Joined: Wed Dec 10, 2003 5:26 pm
Post
by Logan Rhodehamel » Fri Oct 26, 2007 5:40 pm
The categories list a series of integers - IDs of the associated categories. Looking at it now, I think this is less than optimal but not something easily changed at this stage.
I can't find a way for that to be used effectively in nVelocity. It would probably require a simple custom control to do this.
Cheers,
Logan
.com
If I do not respond to an unsolicited private message, it's not because I'm ignoring you. It's because the answer to your question is valuable to others. Try the new topic button.
-
Will
- Captain (CAPT)
- Posts: 263
- Joined: Fri Oct 05, 2007 8:02 am
Post
by Will » Sat Oct 27, 2007 11:20 am
If we can list the id numbers, that would be okay as well. Going to use them to conditionally show chunks of html code. A number is as good as a name here.
Would we reference $cf.Category.Id (???)
So it would look something like...
#foreach($cf in $Product.Categories)
#if ($cf.Category.Id == 1)
<p>Category One Text</p>
#end
#if ($cf.Category.Id == 2)
<p>Category Two Text</p>
#end
#end
This would get the job done for us -- we've got pretty tight control over when categories are created in the catalog and are only interested in showing certain ones anyways.
Just need to know the syntax to get the category id number as we loop through.
Thanks.
-
Logan Rhodehamel
- Developer
- Posts: 4116
- Joined: Wed Dec 10, 2003 5:26 pm
Post
by Logan Rhodehamel » Sat Oct 27, 2007 12:15 pm
Just use $cf - this is the integer ID of the category.
#foreach($cf in $Product.Categories)
#if ($cf == 1)
<p>Category One Text</p>
#end
Cheers,
Logan
.com
If I do not respond to an unsolicited private message, it's not because I'm ignoring you. It's because the answer to your question is valuable to others. Try the new topic button.
-
Will
- Captain (CAPT)
- Posts: 263
- Joined: Fri Oct 05, 2007 8:02 am
Post
by Will » Sat Oct 27, 2007 12:31 pm
Fantastic. Thanks!