Main
Index
Search
Posts
Who's
Online
Log
In

Home: Products: CMS Builder:
Selected item in nav using _isSelectedBranch

 

 


theclicklab
User

Jan 7, 2012, 4:10 PM

Post #1 of 6 (1615 views)
Shortcut
Selected item in nav using _isSelectedBranch Can't Post

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:


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
~~~~~~~~~~~~~~~~~~
Jan Dunlop
theClickLab.com
nz.linkedin.com/in/jandunlop
~~~~~~~~~~~~~~~~~~


Jason
Staff / Moderator


Jan 8, 2012, 6:08 PM

Post #2 of 6 (1559 views)
Shortcut
Re: [theclicklab] Selected item in nav using _isSelectedBranch [In reply to] Can't Post

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 - Programmer 
interactivetools.com

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


theclicklab
User

Jan 8, 2012, 11:26 PM

Post #3 of 6 (1530 views)
Shortcut
Re: [Jason] Selected item in nav using _isSelectedBranch [In reply to] Can't Post

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
~~~~~~~~~~~~~~~~~~
Jan Dunlop
theClickLab.com
nz.linkedin.com/in/jandunlop
~~~~~~~~~~~~~~~~~~
Attachments: page.php (8.14 KB)


Jason
Staff / Moderator


Jan 9, 2012, 9:31 AM

Post #4 of 6 (1518 views)
Shortcut
Re: [theclicklab] Selected item in nav using _isSelectedBranch [In reply to] Can't Post

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 - Programmer 
interactivetools.com

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


davidcmsb
User

Jan 9, 2012, 12:36 PM

Post #5 of 6 (1509 views)
Shortcut
Re: [Jason] Selected item in nav using _isSelectedBranch [In reply to] Can't Post

Hi Jason,
I have a question about what you wrote --


In Reply To
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




Does _isSelectedBranch work if you use
'selectedCategoryNum' => @$_REQUEST['category'],
instead of the default behavior of looking at the number at the end of the URL or setting a static 'selectedCategoryNum'
?

What you wrote seems to say that _isSelectedBranch will only ever be set if $selectedCategory has a value, and the $selectedCategory has a value ONLY if (a) there is a record number at the end of the URL or (b) if you set 'selectedCategoryNum' in your getCategories. But what about using instead of these two ways, using 'selectedCategoryNum' => @$_REQUEST['category'],
?


(This post was edited by davidcmsb on Jan 9, 2012, 9:04 PM)


Jason
Staff / Moderator


Jan 10, 2012, 8:42 AM

Post #6 of 6 (1419 views)
Shortcut
Re: [davidcmsb] Selected item in nav using _isSelectedBranch [In reply to] Can't Post

Hi Jan,

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

ie

Code
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 - Programmer 
interactivetools.com

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