Category Lineage from $_REQUEST call

5 posts by 2 authors in: Forums > CMS Builder
Last Post: October 18, 2011   (RSS)

Re: [Perchpole] Category Lineage from $_REQUEST call

By Jason - October 17, 2011

Hi Perch,

Once you've selected the current category, the parent number is part of that record. For example:

<?php echo $selectedRecord['parentNum']; ?>

So, in your example, if the record num of $selectedCategory is 3, then $selectedRecorc['parentNum'] would be 2.

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] Category Lineage from $_REQUEST call

Hi, Jason -

Thanks for such a speedy response.

I'm actually looking to find the parent category of the selected category.

In the above example - where the category lineage is 1:2:3 - when I select category 3 I need a way to look back up the branch to find category 2.

:o/

Perch

Re: [Perchpole] Category Lineage from $_REQUEST call

By Jason - October 18, 2011

Hi Perch,

You can use the parentNum field of selectedCategory in a where clause to retrieve the parent record.

If you are using CMSB 2.08 or greater, you can use the mysql_get() function like this:

EXAMPLE:

list($categoryRecords, $selectedCategory) = getCategories(array(
'tableName' => 'categories'
));

$parent = array();

if ($selectedCategory) {
$parent = mysql_get('categories', $selectedCategory['parentNum']);
}


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] Category Lineage from $_REQUEST call

Brilliant. Thanks.

:0)

Perch