Filtering one most recent record per category

14 posts by 5 authors in: Forums > CMS Builder
Last Post: June 8, 2010   (RSS)

Re: [Jason] Filtering one most recent record per category

By studio-a - June 8, 2010

Hi Jason,

Thanks for asking. We will need to limit the number of Service Titles per category.

Your help is greatly appreciate!

studio-a

By Jason - June 8, 2010

Hi,

Okay, all we have to do is limit the number that we output. We can change our output code to this:

<?php $maxCount=8; ?>
<?php foreach($Services as $key=>$service): ?>
<?php if(is_array($service)): ?>
<ul>
<li><?php echo $categoryNumToName[$key];?></li>
<ul>
<?php $currentCount=0; ?>
<?php foreach($service as $item): ?>
<?php if($currentCount<$maxCount): ?>
<li><?php echo $item ?></li>
<?php $currentCount++; ?>
<?php endif ?>
<?php endforeach ?>
</ul>
</ul>
<?php endif ?>
<?php endforeach ?>


The variable $maxCount is set to whatever the maximum number of titles we want displayed per category. In this example, it's 8 but you can change that to whatever you want.

Give this a try and let me know how you make out.
---------------------------------------------------
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] Filtering one most recent record per category

By studio-a - June 8, 2010

You Guys Rock!

When we created the navigation we didn’t realize the snags while listing of Services and Categories menu, but Jason you solved our problem! Reading your code helps us improve our entry level of php skills too.

Everyone here has always been very helpful and we cannot say thank you enough. CMS Builder fits our company’s needs and we continue to sell it every chance we can. You guys take suggestions and make this product even better. We have a good majority of the plug-ins and look forward to new features for the upgrades. Interactive Tools is simply good business!

Thanks again for your help!

studio-a