Silly(?) Question re: conditional lists

5 posts by 2 authors in: Forums > CMS Builder
Last Post: November 9, 2010   (RSS)

Re: [danwilson] Silly(?) Question re: conditional lists

By Jason - November 8, 2010

Hi Dan,

What you can do is use an if statement at the beginning of your foreach loop to check to see if there's a value for name_sp like this:

<?php foreach ($about_usRecords as $categoryRecord): ?>
<?php if($categoryRecord['name_sp']): ?>
<?php echo $categoryRecord['_listItemStart'] ?>
<?php if ($categoryRecord['_isSelected']): ?><b><a href="<?php echo $categoryRecord['_link'] ?>"><?php echo $categoryRecord['name_sp'] ?></a></b>
<?php else: ?><a href="<?php echo $categoryRecord['_link'] ?>"><?php echo $categoryRecord['name_sp'] ?></a>
<?php endif; ?>
<?php echo $categoryRecord['_listItemEnd'] ?>
<?php endif ?>
<?php endforeach; ?>


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: [Jason] Silly(?) Question re: conditional lists

By danwilson - November 8, 2010

Thanks for the quick reply, Jason - that works like a champ!
I'm getting better at if/then/else logic, but that one had me vexed...

This is going to help me create some really elegant solutions for multi-lingual sites!

-Dan

Re: [danwilson] Silly(?) Question re: conditional lists

By danwilson - November 9, 2010 - edited: November 9, 2010

I launched the multi-language versions of these two sites yesterday:

www.calloan916.com (A Sacramento, CA pawn shop) and
www.carequityloans.com (their sister site for title loans)

I use cookies to set the language preference, and CMSB to send the right contents. Works like a champ, and now I can offer this type of solution to anyone!

Thanks again, Jason!

Re: [danwilson] Silly(?) Question re: conditional lists

By Jason - November 9, 2010

Hi Dan,

No problem. I'm glad to hear that everything is working well.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

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