Mini Navigation Woe!

6 posts by 2 authors in: Forums > CMS Builder
Last Post: May 17, 2012   (RSS)

Re: [Perchpole] Mini Navigation Woe!

By robin - May 15, 2012

Hey Perch,

If you set Films as your root category, it should just display what you've added in red. You have a different result? What does your getCategories call look like?

Thanks,
Robin
Robin
Programmer
interactivetools.com

Re: [robin] Mini Navigation Woe!

By Perchpole - May 15, 2012

Hi, Robin -

Thanks for your help.

I'm using a general getCategories call - which grabs every category. I need this for the main navigation system which is at the top of every page.

What I'm trying to do is (somehow) filter those results - further down the page - to return just those required for the mini nav.

It can be done (with a battery of if(): statements) but it gets horribly clunky!

As I said in my original post, I'm relying on a host of _IsSibblingSelected, _isAncestor, etc, etc, calls - but I suspect I'm not making best use of the ['breadcrumb'] and ['_lineage'] options.

:0)

Perch

Re: [Perchpole] Mini Navigation Woe!

By robin - May 15, 2012

The "rootCategoryNum" parameter might be exactly what you need. Just use the num of "Films" instead of 0

e.g:

list($categoryRecords, $selectedCategory) = getCategories(array(
'tableName' => 'category',
'rootCategoryNum' => '0', // Only categories _below_ this one will be shown (defaults to 0 for all)


Hope that helps,
Robin
Robin
Programmer
interactivetools.com

Re: [robin] Mini Navigation Woe!

By Perchpole - May 15, 2012

OK, but I don't want to enter the Film num manually. I want to pass the value with some code. That way it will work on any page.

Lets assume I set up a checkbox on the category editor called "root". I would activate this for the "Films" category.

So, now if the page being viewed is the Films page I can use something like this to pass the value to the code:
<?php if ($selectedCategory['root']): ?>
...
'rootCategoryNum' => $selectedCategory['num']
...
etc


However, if the current page is a sub-category page - like the "Comedy" category - how do I look back up the hierarchy and assign the parent num to 'rootCategoryNum' ?

:0/

Perch

Re: [Perchpole] Mini Navigation Woe!

By robin - May 17, 2012

Hey,

If you always want the 2nd level category to be the root of the menu, you can find out it's num from the "lineage" field in your current category.
It's a comma separated field that will look something like this:
:17:19:20:

Hope that helps,
Robin
Robin
Programmer
interactivetools.com