Get Parent Level

Permalink
Hello!

I've got a weird autonav issue. I've got navigation that appears like this:

Clothing
>Shirts
>>Black Top (Product Detail Page)
>Bottoms
>Dresses

Shoes
>Black Heels (Product Detail Pages)

I've got Product Detail pages that appear on 2nd and 3rd levels. I want the Auto Nav to ONLY display when the Products are on a 3rd level. So the Black Top under Shirts would have a nav (that shows Shirts, bottoms and etc). And the Black Heels under shoes wouldn't display an auto nav because it's on the 2nd level. Does that make sense? I tried playing around with the getCurrentPage, but couldn't wrap my mind around it. I can autonav to display properly but can't figure out how to tell it when to show and when not to.

rainmaker
View Replies: View Best Answer
rainmaker replied on at Permalink Reply
rainmaker
Anyone?
Mnkras replied on at Permalink Best Answer Reply
Mnkras
This is just an idea and it may not be the best way,

get the current page, check if the parent cID is 1 if it is its on the second level, if it isn't, then get the parent ID of that page, if its 1 then its the 3rd level.

Mike
rainmaker replied on at Permalink Reply
rainmaker
Ah good idea. :) Thanks!
JohntheFish replied on at Permalink Reply
JohntheFish
The 'Parent Area' addon (in the prb, but you have a copy) climbs up ancestors to find Grandparents, Great Grandparents etc, counting ancestors until it finds a level of ancestor or hits a ceiling at home. What you are looking for is essentially the same algorithm, but just getting the count rather than the actual area. Feel free to extract that part of the code.
JohntheFish replied on at Permalink Reply
JohntheFish