Content to Show up only if there

5 posts by 2 authors in: Forums > CMS Builder
Last Post: February 8, 2012   (RSS)

Re: [kcmedia] Content to Show up only if there

By (Deleted User) - February 7, 2012

Hi Craig,

The best thing to do is wrap those elements in an IF statement so that they only show up if there is anything to show:

[url]
<?php if ( @$record['twitter_url'] ): ?>
<a class="twitter" href="<?php echo $record['twitter_url'] ?>" target="_blank"></a>
<?php endif; ?>

<?php if ( @$record['facebook_url'] ): ?>
<a class="facebook" href="<?php echo $record['facebook_url'] ?>" target="_blank"></a>
<?php endif; ?>

[/url]

Of course if the anchor tags are important to the layout you'll have to replace them with something else (a span with the same properties, for example).

Let me know if this helps,

Tom

Re: [Tom P] Content to Show up only if there

By KCMedia - February 8, 2012

Hi Tom

i got it working like this

<?php if ($record['twitter_profile_on'] == "1"): ?><a class="twitter" href="<?php echo $record['twitter_url'] ?>" target="_blank" ><img src="images/twitter.png" alt="Twitter" title="Twitter" width="16" height="16" /></a><?php endif ?>
<?php if ($record['facebook_profile_on'] == "1"): ?><a class="facebook" href="<?php echo $record['facebook_url'] ?>" target="_blank" ><img src="images/facebook.png" alt="Facebook" title="Facebook" width="16" height="16" /></a><?php endif ?>
Thanks



Craig

KC Media Solutions

www.kcmedia.biz

Re: [kcmedia] Content to Show up only if there

By (Deleted User) - February 8, 2012

Hi Craig,

Just noticed that the code for my response never posted!

Sorry about that, but you clearly got the meaning which is what's important.

Thanks,

Tom

Re: [Tom P] Content to Show up only if there

By KCMedia - February 8, 2012

Hi Tom

no worries i worked it all out thanks.
Thanks



Craig

KC Media Solutions

www.kcmedia.biz