Subcategories with CMS Builder?

6 posts by 3 authors in: Forums > CMS Builder
Last Post: February 26, 2008   (RSS)

By rasbro - January 23, 2008 - edited: January 24, 2008

Thanks Dave for the quick run down on the differences. One looming question I still have is how CMS Builder will handle sub-categories. It seems that CMS Builder doesn't do this automatically. Any thoughts on how I would accomplish category and sub-category structure?

Brian

Re: [rasbro] CMS Builder vs Article Manager

By Dave - January 23, 2008

There's no slick easy way. Do you have an example of what you're trying to accomplish? I'm sure we can come up with something.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] CMS Builder vs Article Manager

By rasbro - January 23, 2008

Here is an example of typical category nesting I will need:

Main Category (level 1)
--> Sub-category (level 2)
-----> Sub-category (level 3)
--------> Products
--> Sub-category (level 2)
-----> Sub-category (level 3)
--------> Products

Here it is with some real life examples:

Shop Outdoor Gear (level 1)
--> Camping (level 2)
-----> Sleeping Bags (level 3)
--------> Mummy Sleeping Bags (product listings)
--> Hiking (level 2)
-----> Backpacks (level 3)
--------> Day Packs (level 4)
-----------> X-Brand Day Packs (product listings)

Typically I only need to go 2-3 levels but sometimes I might need more than 3 levels of nested categories like with the last example.

Thanks,
Brian

Re: [rasbro] CMS Builder vs Article Manager

By Dave - January 24, 2008

Hi Brian,

There's no automatic way to do it (we hope to make it simpler in future) but I have some options. Here's what I did.

I created a new section called "My Categories" with fields for: Category Name, Category Breadcrumb, and Category Depth. I set it to sort by breadcrumb. Then, I manually entered each category like this:

Name: Sleeping Bags
Breadcrumb: Shop Outdoor Gear > Camping > SleepingBags
Depth: 2

Then I created a view with these custom options so it would show all the categories:

$options['perPage'] = '9999';
$options['orderBy'] = 'breadcrumb, name';
$options['pageNum'] = '1';
$options['where'] = '1';


And use this code to show a breadcrumb list:

<h1>My Categories List Viewer</h1>
<?php foreach ($listRows as $record): ?>
<?php echo htmlspecialchars($record['breadcrumb']); ?><br/>
<?php endforeach ?>

Outputs:

Shop Outdoor Gear
Shop Outdoor Gear > Camping
Shop Outdoor Gear > Camping > Sleeping Bags


And this code to show a tree list:

<?php foreach ($listRows as $record): ?>
<?php
$padding = "&nbsp; &nbsp; &nbsp; ";
echo str_repeat($padding, $record['depth']-1); ?>
<?php echo htmlspecialchars($record['name']); ?><br/>
<?php endforeach ?>

Outputs:

Shop Outdoor Gear
Camping
Sleeping Bags
Hiking


Will that work for you? Want to give it a try? The only downfall is it's a bit more tedious entering the categories.

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] CMS Builder vs Article Manager

By Djulia - February 26, 2008 - edited: February 26, 2008

Hi Dave,

There is another solution to create an additional level (level 3) in a section ?

I would like to obtain this example:

Main Category (level 1)
--> Sub-category (level 2)
-----> Sub-category (level 3)
--------> Products
--> Sub-category (level 2)
-----> Sub-category (level 3)
--------> Products

The solution that you propose is difficult for a simple editor.
It requires the intervention of the administrator (who can be the vendor sometimes [;)]).

Thank you for your suggestion.

Djulia