Sub-categories Tutorial

134 posts by 17 authors in: Forums > CMS Builder
Last Post: August 7, 2012   (RSS)

Re: [chris] Sub-categories Tutorial

Chris,

Thanks for this much needed tutorial

Very clear and concise.

Best,

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [chris] Sub-categories Tutorial

By flamerz - January 25, 2010 - edited: January 26, 2010

this works great.

could be possible to have some identation inside the article pulldown (inside cms builder)?

for example, if we have fruits:apples and fruits:oranges.. the pulldown could show:
[pre]
fruits
apples
oranges
[/pre]

instead of

fruits
apples
oranges

Note: i updated my entry form with the <?php echo $ESCAPED_FILTER_VALUE ?> trick.

nice way to populate a list from another.

Re: [flamerz] Sub-categories Tutorial

By Chris - January 26, 2010 - edited: January 27, 2010

Hi flamerz,

Not quite, but you can achieve something similar by choosing:

Use this field for option labels: breadcrumb

This will give you a pulldown with these options:

fruits
fruits : apples
fruits : oranges


I hope this helps! Please let me know if you have any questions.
All the best,
Chris

Re: [chris] Sub-categories Tutorial

By paulmac - January 27, 2010

Hi Chris

I can get this working to a point, but you may be able to give me some pointers or assistance with the following:

I want to set the menus up as following:

PRODUCTS
(when a user selects this link, they get taken to a new page with an overview of all their products and a list/menu of all the Product Categories:

This new page will display the following menu:

PRODUCT1
PRODUCT2
PRODUCT3
PRODUCT4
PRODUCT5

When the user selects PRODUCT2 from these options, they will be taken to a new page with an overview of PRODUCT2 and a menu like below:

PRODUCT1
PRODUCT2
product2_1
product2_2
product2_3
PRODUCT3
PRODUCT4
PRODUCT5


When the user selects product2_1 from these options, they will be taken to a new page with an overview of product_2 and a menu the same as the previous one.

Hope this all makes sense, I would appreciate any help with it.

Thanks.

Re: [paulmac] Sub-categories Tutorial

By Chris - January 27, 2010 - edited: January 27, 2010

Hi paulmac,

Does this help? Try adding this line (in red):

list($categoriesRecords, $selectedCategory) = getCategories(array(
'tableName' => 'categories',
'categoryFormat' => 'onelevel',
));


I hope this helps! Please let me know if you have any questions.
All the best,
Chris

Re: [chris] Sub-categories Tutorial

By paulmac - January 27, 2010

Hi Chris

Thanks for getting back so quickly. I think I'm edging closer to the solution, but a combination of my poor php skills and not quite understanding how the Viewer URLS work is holding me back I think.

Whe I complete the tutorial and create the page articleList.php, I have a page displaying the following:

Categories
•(All Articles)
•Dogs
•Cats

Articles - List Page Viewer
Chihuahuas Article
Cat Article 1
Dog Article 1

If I click on Dogs the following appears on the page, replacing what was previously on articlesList.php:

Categories
•(All Articles)
•Dogs
&#9702;Chihuahuas
•Cats

Articles - List Page Viewer
Dog Article 1

What I want to happen is when I click on Dogs, the user gets taken to a new page with an overview about Dogs and a menu like below:

•Dogs
&#9702;Chihuahuas
•Cats

I feel like I'm dragging this out, but as I say I'm quite inexpereinced with both php and CMSB.

Thanks again for your help.

Re: [paulmac] Sub-categories Tutorial

By Chris - January 28, 2010 - edited: January 28, 2010

Hi paulmac,

For simplicity, the tutorial is only concerned with a single viewer. If you need to specialize the behaviour of your pages depending on whether or not a category is selected, (e.g. removing the "(All Articles)" link,) you can either use separate viewers or check $selectedCategory (note that if there is no selected category, the variable will be an empty array, see below for an example.)

Displaying an overview of your category can be accomplished with the Category section's "content" wysiwyg field:

<?php if (!empty($selectedCategory)): ?>
Selected Category: <?php echo $selectedCategory['name'] ?><br />
<?php echo $selectedCategory['content'] ?><br />
<?php else ?>
No Category Selected.<br />
<?php endif ?>


I hope this helps! Please let me know if you have any questions.
All the best,
Chris

Re: [chris] Sub-categories Tutorial

Are you able to bring in any images that are related to the article as well or just text? If you can bring in imagesthen what is the difference between Categories, subcategories and the relatedrecordslookup plugin?

Re: [Dan Maitland] Sub-categories Tutorial

By Chris - March 30, 2010

Hi Dan,

Categories and Sub-categories are the same thing, really. They can have uploaded images, yes, and getCategories will load them.

The relatedrecordslookup plugin is something completely different.
All the best,
Chris