Having menu nav subs limit the number to display

5 posts by 2 authors in: Forums > CMS Builder
Last Post: December 12, 2009   (RSS)

Re: [drewh01] Having menu nav subs limit the number to display

By Chris - December 10, 2009

Hi drewh01,

I'm not sure I understand what you mean by sub navigation. Can you please explain what the problem is exactly, preferably with an example showcasing the issue?
All the best,
Chris

Re: [chris] Having menu nav subs limit the number to display

On this page: http://65.99.232.147/articles/articles.php you will see the "Articles" link and subnavigation. Right now I only have 4 articles in there, but over time many articles will build up. What I need to do is to only allow the first 10 to appear as a sub nav link to the detail page.

This way if they place 100 articles in there will not be 100 subnav links.

Re: [drewh01] Having menu nav subs limit the number to display

By Chris - December 11, 2009

Hi drewh01,

If you add these two lines in red, your foreach will stop after displaying ten records:

<?php $count = 0; ?>
<?php foreach ($categoryRecords as $categoryRecord): ?>
<?php $count++; if ($count > 10) { break; } ?>
<?php if ($categoryRecord['url']) { $categoryRecord['_link'] = $categoryRecord['url']; } ?>
<?php echo $categoryRecord['_listItemStart'] ?>
<a href="<?php echo $categoryRecord['_link'] ?>"><?php echo $categoryRecord['name'] ?></a>
<?php echo $categoryRecord['_listItemEnd'] ?>
<?php endforeach; ?>


I hope this helps! Please let me know if you have any questions.
All the best,
Chris

Re: [chris] Having menu nav subs limit the number to display

Very helpful, thanks!