
Collin
Novice

Dec 5, 2011, 9:41 PM
Post #4 of 7
(1197 views)
Shortcut
|
|
Re: [theclicklab] Sub Category Display - When Empty
[In reply to]
|
Can't Post
|
|
I can't see an attachment, but I think I see where the problem is. You're actually filtering out when depth == 0 in the foreach loop, so the pagesRecords is not actually empty. Perhaps try this when you are getting the records:
<?php // Subcat navigation - First Level list($pagesRecords, $pagesMetaData) = getCategories(array( 'tableName' => 'pages', 'selectedCategoryNum' => '', // defaults to getNumberFromEndOfUrl() 'loadUploads' => '0', 'where' => 'depth <> 0', // filter out the depth of 0 <---------- // 'debugSql' =>'true', )); ?> Edit: I just noticed you have further filtering on this line: <?php if($record['hide']==0 && $record['parentNum']==$selectedCat): ?> We should probably add these filters to the getCategories call too. $selectedCat = pagesRecord['num'] <-- not sure where pagesRecord is defined. It'll probably be more clear when I see the attachment. Could you try attaching it again? Thanks. Edit2: I just thought of another solution that will require less rewriting of your code:
<?php $links = ''; ?> <?php foreach ($pagesRecords as $record): ?> <?php if ($record['depth'] == 0) { continue; } ?> <?php if($record['hide']==0 && $record['parentNum']==$selectedCat): ?> <?php $links .= '<li><a href="' . $record['_link'] . '">' . htmlspecialchars($record['name']) . '</a></li>'; ?> <?php endif ?> <?php endforeach; ?> <?php if (!empty($links)): ?> <h2>In this Section:</h2> <ul> <?php echo $links; ?> </ul> <?php endif; ?>
(This post was edited by Collin on Dec 5, 2011, 10:02 PM)
|