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
Brian
Re: [rasbro] CMS Builder vs Article Manager
By Dave - January 23, 2008
interactivetools.com
Re: [Dave] CMS Builder vs Article Manager
By rasbro - January 23, 2008
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
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 = " ";
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!
interactivetools.com
Re: [Dave] CMS Builder vs Article Manager
By Djulia - February 26, 2008 - edited: February 26, 2008
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
Re: [Djulia] CMS Builder vs Article Manager
By Dave - February 26, 2008
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.
interactivetools.com