"If" " and" syntax problem

5 posts by 3 authors in: Forums > CMS Builder
Last Post: December 18, 2008   (RSS)

Re: [gkornbluth] "If" " and" syntax problem

By ross - December 17, 2008

Hi.

Thanks for posting!

Instead of the word "and" could you try "&&" like this:

<?php if (!$record['print_price']) && ($!record['full_description']):?>

Let me know how you make out with that :)
-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

Re: [gkornbluth] "If" " and" syntax problem

By Dave - December 17, 2008

And remove the extra ) and (. Then replace $! with !$. sometimes I add spaces to make it clearer:

<?php if ( !$record['print_price'] && !$record['full_description'] ): ?>
...
<?php endif ?>


Hope that helps!
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] "If" " and" syntax problem

By gkornbluth - December 17, 2008 - edited: December 17, 2008

thank you both,

Here;s what I cobbled together, although I have a feeling that it's not the most elegant approach and I'm open to suggestions. This works with Milkbox which is a lightbox derivative so that when the various combination of selling price and description occur, the appropriate message appears under the title.

http://www.elleschorrphotography.com/cmspeople4.php

<table border="0" id="gallery" cellspacing="0" cellpadding="10" align="center">
<tr valign="middle">
<?php foreach ($peopleRecords as $record): ?><?php foreach ($record['image'] as $upload): ?>
<td align="center" valign="middle" <?php echo $record['border'] ?> width="15%">
<div align="center">
<?php if ($upload['hasThumbnail']): ?>
<a href="<?php echo $upload['urlPath'] ?>" rel="milkbox[people]" title="
<?php if (!$record['print_price'] && !$record['full_description']): ?>?php echo $record['title'] ?><?php endif ?>

<?php if ($record['print_price'] && !$record['full_description']): ?><a href=&quot;<?php echo $record['_link'] ?>&quot;><?php echo $record['title'] ?></a><br>Click title for more information or to buy a print.<?php endif ?>

<?php if ($record['print_price'] && $record['full_description']): ?><a href=&quot;<?php echo $record['_link'] ?>&quot;><?php echo $record['title'] ?></a><br>Click title for more information or to buy a print.<?php endif ?>

<?php if (!$record['print_price'] && $record['full_description']): ?><a href=&quot;<?php echo $record['_link'] ?>&quot;><?php echo $record['title'] ?></a><br>Click title for more information<br />about this image.<?php endif ?>">

<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight']?>" /></a>
<?php endif; ?>
</div></td>
<?php $maxCols=7; if (@++$count % $maxCols == 0): ?></tr><tr><?php endif; ?>
<?php endforeach ?>
<?php endforeach ?>
</tr>
</table>
The first CMS Builder reference book is now available on-line!

Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [gkornbluth] "If" " and" syntax problem

By Dave - December 18, 2008

Jerry, thanks for posting back. Great to hear it's working! :)
Dave Edis - Senior Developer
interactivetools.com