isSiblingSelected?

13 posts by 3 authors in: Forums > CMS Builder
Last Post: July 20, 2011   (RSS)

By Perchpole - June 30, 2011

Dave -

Just a thought...

Seeing as we have the entire family, could we not join them all together...

_isParentSelected
_isChildSelected
_isSiblingSelected
---------------------------------
=_isFamilySelected

...or is that a step too far?!

:0)

Perch

By Mikey - July 1, 2011

Perch,
I'm assuming this code goes in your page head:
<?php
$subMenuLinks = "";
foreach ($categoryRecords as $menuCategory) {
if ($menuCategory['_isSelected'] || $menuCategory['_isParentSelected'] || $menuCategory['_isChildSelected']) {
$subMenuLinks[] = $menuCategory;
}
}
?>


Do you mind provide some code showing how you build your categories in the body of your webpage. I'm struggling with it.

Thanks Zick

Hi, Zick -

I'm currently building a site for a large and long-established charity. As such, their "About Us" section contains upwards of 30 different pages across various sub-sections. I wanted to introduce a localised sub-section menu which would enable readers to move around the related pages.

The category tree looks something like this:

[pre]Home
Articles
News
About Us
Our History
Page2
Page3
Page4

Our Founder
Page2
Page3
Page4

Etc...
[/pre]

So, in our example, if a reader was on the "Our History" page, I wanted to display a small menu showing just those links related to that sub-section:

[pre]Our History
Page2
Page3
Page4[/pre]

Achieving this (with simple code) using the current filters was proving difficult. The _isAncestorSelected or _isDecendantSelected snippets returned too many links - often the entire branch of the ancestory tree.

With Dave's updates all I need is this:

<?php
$subMenuLinks = "";
foreach ($categoryRecords as $menuCategory) {
if ($menuCategory['_isSelected'] || $menuCategory['_isParentSelected'] || $menuCategory['_isChildSelected']) {
$subMenuLinks[] = $menuCategory;
}
}
?>


This pulls out only those links which are directly related to each category in the sub-section.

Works a treat!

:0)

Perch