Selected item in nav using _isSelectedBranch

6 posts by 3 authors in: Forums > CMS Builder
Last Post: January 10, 2012   (RSS)

By theclicklab - January 7, 2012

Hi there,

having issues getting a subnav menu to show a selected item. Im trying to use _isSelectedBranch

e.g. $record['_isSelectedBranch'] == 1

Heres the code:

<?php // Subcat Nav - Second Level
list($pagesRecords, $pagesMetaData) = getCategories(array(
'tableName' => 'pages',
'selectedCategoryNum' => '', // defaults to getNumberFromEndOfUrl()
'loadUploads' => '0',
// 'debugSql' =>'true',
));
?>

<?php $selectedCat=$pagesRecord['parentNum']; ?>
<?php $thispagedepth=$pagesRecord['depth']; ?>

<?php if ($pagesRecord['depth'] > 0): ?>
<div class="sidebox subnav">
<h2>In this Section:</h2>
<ul>
<?php foreach ($pagesRecords as $record): ?>
<?php if($record['hidden'] == 0 && $record['parentNum'] == $selectedCat && $record['depth'] == $thispagedepth && $record['_isSelectedBranch'] == 1): ?>
<li><a class="selected" href="/<?php echo strtolower($record['url']); ?>/"><?php echo $record['name'] ?></a></li>
<?php elseif($record['hidden'] == 0 && $record['parentNum'] == $selectedCat && $record['depth'] == $thispagedepth): ?>
<li><a href="/<?php echo strtolower($record['url']); ?>/"><?php echo $record['name'] ?></a></li>
<?php endif ?>
<?php endforeach; ?>
</ul>
</div>
<?php endif ?>


Any suggestions?

Many thanks

Re: [theclicklab] Selected item in nav using _isSelectedBranch

By Jason - January 8, 2012

Hi,

So, if you remove the _isSelectedBranch portion, does the if statement work?

One thing I noticed is that $selectedCat and $thispagedepth are getting their value from $pagesRecord, but I don't see $pagesRecord being set anywhere in your code.

Let me know.

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/

Re: [Jason] Selected item in nav using _isSelectedBranch

By theclicklab - January 9, 2012

Yep, everything works without it.

I assume that Im not setting $pagesRecord correctly?

I have attached the whole file. See around line 126.

Many thanks
Attachments:

page_004.php 9K

Re: [theclicklab] Selected item in nav using _isSelectedBranch

By Jason - January 9, 2012

Hi Jan,

_isSelectedBranch will only ever be set if $selectedCategory has a value. This will either be set if there is a record number at the end of the URL or if you set 'selectedCategoryNum' in your getCategories.

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [davidcmsb] Selected item in nav using _isSelectedBranch

By Jason - January 10, 2012

Hi Jan,

Yes, you can set "selectedCategoryNum" they way you describe,

ie
list($categoryRecords, $selectedCategory) = getCategories(array(
'tableName' => 'categories',
'selectedCategoryNum' => @$_REQUEST['category'],
));


However, this will only work when $_REQUEST['category'] is the record number of category you want $selectedCategory to be.

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/