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: [Djulia] CMS Builder vs Article Manager

By Dave - February 26, 2008

There's no really simple way. We want to make it simple in future. One way would be to have these fields:

Category Name
Category Parent (pulldown of other category nums/names)
Category Breadcrumb

and then use some custom PHP to load the entire category list and display it in the tree format you showed.

Another way would be letting the user specify the depth. But as you say that can be complicated for the user.

Those are the best ways I've come up with so far. I'll post if I can think of any others.
Dave Edis - Senior Developer
interactivetools.com