How to change category display based on categ vs. product

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
ZLA
Commodore (COMO)
Commodore (COMO)
Posts: 496
Joined: Fri Mar 13, 2009 2:55 pm

How to change category display based on categ vs. product

Post by ZLA » Mon May 11, 2009 9:08 pm

On my category pages, if there are categories / sub categories, I want to display a category grid.
If the category only contains products, then I want a display more like the Category Details page.

I'm guessing I can do something like the following psuedo-code:
// get nodes
if (!nodestypes.contain("Products")) {
[[ConLib:CategoryGridPage2]]
} else {
[[ConLib:CategoryDetailsPage]]
}

I know that's not quite right since it mixes scriplets and code behind. Can someone get me started on how to accomplish this? Thanks in advance.

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: How to change category display based on categ vs. product

Post by mazhar » Tue May 12, 2009 5:31 am

A simple solution could be to manually apply category details page on those categories for which you know that they don't have any sub category and for all other you can have category grid page. Do not use NVelocity as programming alternative, its extensive use can slow down your pages. With NVeclocity you can try following solution

Code: Select all

#set($found = 0)
#foreach($cnode in $Category.CatalogNodes)
#if( $found == 0 && $cnode.CatalogNodeType == "Category")
#set($found = 1)
#end
#end
#if($found == 1)
[[ConLib:CategoryGridPage]]
#else
[[ConLib:CategoryDetailsPage]]
#end

ZLA
Commodore (COMO)
Commodore (COMO)
Posts: 496
Joined: Fri Mar 13, 2009 2:55 pm

Re: How to change category display based on categ vs. product

Post by ZLA » Tue May 12, 2009 6:15 am

Thanks Mazhar. While philosophically I prefer the programmatic solution, I've only got about 100 categories in 2 levels. So the configuration solution is very doable.

As a follow-up question, I've seen that same disclaimer about using nVelocity. Can you explain why it is slower than normal .NET programming?

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: How to change category display based on categ vs. product

Post by mazhar » Tue May 12, 2009 6:24 am

NVelocify just replaces its constructs with values from different objects. Basically it is a Template Engine and its purpose is to give end user control on display. For example in Email templates different stores could have different names and NVelocity plugs correct name. So if you are going to target some complex programming solution then it would be better to write a new ConLib instead of writing a bunch of NVelocity code, which will first run by .NET to populate NVelocity parameters and initialize NVeclocity and then further processed by NVelocity to plug correct values.

Post Reply