Category Lineage from $_REQUEST call
5 posts by 2 authors in: Forums > CMS Builder
Last Post: October 18, 2011 (RSS)
Hello All -
I'm trying to derive the category lineage working backwards from a $_REQUEST function.
Let's assume the lineage is: 1:2:3
I then call category 3 using:
I can return the category number by using:
But from this point how do I workout what the parent category number is?
NB: I intend to use this code in the WHERE clause of a getRecords() call.
Thanks in advance.
:o/
Perch
I'm trying to derive the category lineage working backwards from a $_REQUEST function.
Let's assume the lineage is: 1:2:3
I then call category 3 using:
./index.php?category=3
I can return the category number by using:
$_REQUEST['category']
But from this point how do I workout what the parent category number is?
NB: I intend to use this code in the WHERE clause of a getRecords() call.
Thanks in advance.
:o/
Perch
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:
So, in your example, if the record num of $selectedCategory is 3, then $selectedRecorc['parentNum'] would be 2.
Hope this helps
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/
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
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:
Hope this helps
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/
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
:0)
Perch