Categories and Subcategories

6 posts by 2 authors in: Forums > CMS Builder
Last Post: April 16, 2012   (RSS)

Re: [ikanizaj] Categories and Subcategories

By Jason - April 13, 2012

Hi Igor,

What you can do is use the 'rootCategoryNum' option of getCategories() to do this.

For example, if you had a select field called "level1", when it was submitted, you can get all the children of the selected category like this:

EXAMPLE:

<?php
$level1Root = @$_REQUEST['level1'] ? intval($_REQUEST['level1']) : -1 ;

list($level2Records, $level2SelectedRecord) = getCategories(array(
'tableName' => 'categories',
'rootCategoryNum' => $level1Root,
));

?>


In this code, $level2Records would contain all the categories that are a child of the category value selected in level1

Hope this helps
---------------------------------------------------
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] Categories and Subcategories

By ikanizaj - April 13, 2012

hm, but I want that when adding records inside cms, not inside my page.
--
Igor Kani¾aj

Re: [ikanizaj] Categories and Subcategories

By ikanizaj - April 14, 2012

Hi there Jason, just found your answer on what I was regarding to in another post.... [:)]

http://www.interactivetools.com/iforum/Products_C2/CMS_Builder_F35/Category_selection_populates_sub_categories_P91818/
--
Igor Kani¾aj

Re: [ikanizaj] Categories and Subcategories

By ikanizaj - April 14, 2012

SELECT num, title
FROM `<?php echo $TABLE_PREFIX ?>product_sub_category`
WHERE category = '<?php echo $ESCAPED_FILTER_VALUE;?>'

tought this will work, but it only works one level, and when I try to put another level, my pulldown list is displaying "loading" and nothing happens?
--
Igor Kani¾aj

Re: [ikanizaj] Categories and Subcategories

By Jason - April 16, 2012

Hi Igor,

I'm not sure I understand exactly what you're trying to do. Do you have 1 drop down with only top level categories and you want to use that to populate a second drop down with second level categories? The code your using doesn't look like it's referring to a category section at all. If you could provide some more clarification on the set up of the sections you are trying to use and what you need these fields to do, I should be able to put together an example for you.

Thanks,
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

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