Forum

Thread tagged as: Question

Page belongs to which navgroup?

Hi All

I'm sure there is a quicker way to do this, but I just want to capture which navgroup the current page belongs to so I can display certain content accordingly. I'd rather not sort through each navgroup to see if the page exists in there.

As an example, in the CMS itself, the Page Options tab does this for a particular page. It has it's navgroup ticked. That's what I'm after.

Thanks in advance.

Michael Wilkinson

Michael Wilkinson 6 points

  • 7 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

There's no public API to get a page's nav groups.

I can't guarantee this will work forever, as it's a private API, but it's pretty stable and I can't see why it would change.

$PerchContent = PerchContent::fetch();
$Page = $PerchContent->get_page();
$groups = $Page->get_navgroup_ids();
Michael Wilkinson

Michael Wilkinson 6 points
Registered Developer

Cracking stuff, thanks a million Drew.