Setting up categories, subcategories and records

6 posts by 3 authors in: Forums > CMS Builder
Last Post: August 16, 2011   (RSS)

Re: [coliva] Setting up categories, subcategories and records

By Jason - August 15, 2011

Hi Claudia,

It sounds like you're off to a pretty good start.

To make sure I understand how you'd like to structure things, you want to have a list of product categories (ie, cheeses, sauces, etc). Each product category will have one or more brands associated with it. Finally, you'll have individual products that will be associated with both a brand and a product category.

Does that sound right?

If so, you can probably accomplish all of this by using only 3 sections. The problem with setting up different sections to handle different product types is that you'll need to have separate viewer pages to be able to handle them. If they all have the same fields, you can get away with just having one.

Start by create 1 section to have your list of categories, and 1 section to have your list of brands. In your brand section, you can have a drop down list (pull down or multi-value, depending on what you need) where you can associate a brand with 1 (or more) product categories. That way, when someone list selects a category, you'll be able to get a list of brands associated with that category.

Finally, in your products section, you can have 1 list to associate your product with a category, and 1 list to associate your product with a brand. The reason you would have both lists is so you can get a list of products either by category or by brand. This will also help if you have a brand that appears in more than 1 category.

Unless your product category section is going to have any sub levels, you probably don't even need to use a category section. If you do need to use a category section, here is a good post to help get you started with sub categories:

http://www.interactivetools.com/forum/gforum.cgi?post=77230

Here is another article with tips on using the records in 1 section to be a list of values in another section:
http://www.interactivetools.com/kb/article.php?Populate-a-list-field-from-another-section-15

Hope this helps get you started. Please let us know if you run into any problems
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Setting up categories, subcategories and records

By coliva - August 15, 2011

Thank you so much Jason. Yes, the structure is as you stated. I will try this solution out and let you know if I have any other questions.

Re: [coliva] Setting up categories, subcategories and records

By coliva - August 15, 2011

Hi Jason,

I'm working on nesting the list or records from my brandList viewer into my product_categoryDetail page, but wanted to know how to limit the list so that only the brands that pertain to the selected product category display. I'm sure it involves an IF statement and the values of the pulldown lists, but i'm not certain how to write this out. Could you help me here please?

The same would apply for nesting the list of records from my productsList viewer into my brandDetail page.

I read the post by Chris describing how to set up a categories list to show the records, but in my case i'm not using a category menu item but instead just the records lists.

Here's what my code looks like:

// load records
list($product_categoriesRecords, $product_categoriesMetaData) = getRecords(array(
'tableName' => 'product_categories',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));

list($brandsRecords, $brandsMetaData) = getRecords(array(
'tableName' => 'brands',
));

$product_categoriesRecord = @$product_categoriesRecords[0]; // get first record


And how I'm displaying the records:
<h1><?php echo $product_categoriesRecord['title'] ?></h1>

<?php foreach ($brandsRecords as $record): ?>
<a href="<?php echo $record['_link'] ?>"><?php echo $record['title'] ?></a><br/>
<?php endforeach ?>

Re: [coliva] Setting up categories, subcategories and records

By coliva - August 16, 2011

I figured out how to write the condition to only show only the links pertaining to the selected brand within the detail page:

<h1><?php echo $product_categoriesRecord['title'] ?></h1>

<?php foreach ($brandsRecords as $record): ?>
<?php if ($record['product_category'] == (int)$product_categoriesRecord['num']): ?>
<a href="<?php echo $record['_link'] ?>"><?php echo $record['title'] ?></a><br/>
<?php endif ?>

<?php endforeach ?>

[:)]

Re: [coliva] Setting up categories, subcategories and records

By ross - August 16, 2011

Hi Coliva

Thanks for the update! Glad to hear you got that going. Keep us up to date with how you are making out. Thanks!
-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/