'parentNum' numbers issue

3 posts by 2 authors in: Forums > CMS Builder
Last Post: September 16, 2013   (RSS)

By CarlosPinedo - September 14, 2013 - edited: September 14, 2013

Hi

I'm trying to use 'parentNum' field number to define the class of a 'name' :

<li><a href="<?php echo htmlencode($listRecord['_link']) ?>" class="bll_ora<?php echo htmlencode($listRecord['parentNum']) ?>"><?php echo htmlencode($listRecord['name']) ?></a></li>

My classes are: "bll_ora0" , "bll_ora1", "bll_ora2", "bll_ora3",  "bll_ora4" , so the idea it´s that the final digit changes depending of the 'parentNum numbe

the problem is that only from the, top level categories, and, second level categories, I can get a predictable number: "0" for the top level categories and "1" from the second level categories. After, is caos, For instance, the numbers that I get from third level categories are as different as 2 or 10 or 13. 

So i guess my question is how does it work the 'parentNum' field numbers, especially after third level categories. And, is it possible to obtain predictible numbers out of the parentNum field ?

By Jason - September 15, 2013

Hi,

The parentNum field, with the exception of top level categories, is never predictable since it's just the record number of the parent category.  A better field to use if you want something predictable is the depth field.  This field indicates how many levels deep the record is.  Top level categories, have a depth of 0, second level categories have a depth of 1, third level categories have a depth of 2, etc.

Hope this helps.  Please let me know if you have any other questions.

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/