Content to Show up only if there
5 posts by 2 authors in: Forums > CMS Builder
Last Post: February 8, 2012 (RSS)
By KCMedia - February 7, 2012
i have this these text boxes that have links in them that display images to twitter or facebook pages for each person in a profile, how can i make it so that if there is no data in the text box that the image and the link wont show up.
here is the link to the page
http://www.driveravenuegroup.com/talent.php
and here is the page code for that section.
<div class="page-content talent-content scroll-pane">
<ul class="list clearfix">
<?php foreach ($our_talentRecords as $record): ?>
<li>
<?php foreach ($record['profile_upload'] as $upload): ?>
<?php if ($upload['hasThumbnail']): ?>
<p class="image"><img src="<?php echo $upload['thumbUrlPath'] ?>" alt="" /><?php endif ?>
<?php endforeach ?></p>
<h3 class="name"><?php echo $record['profile_name'] ?></h3>
<p class="address"><?php echo $record['teams'] ?></p>
<p class="more">
<a class="twitter" href="<?php echo $record['twitter_url'] ?>" target="_blank"></a>
<a class="facebook" href="<?php echo $record['facebook_url'] ?>" target="_blank"></a>
<?php foreach ($record['profile_file'] as $upload): ?>
<a class="profile" href="<?php echo $upload['urlPath'] ?>" target="_blank">VIEW PROFILE</a>
<?php endforeach ?>
</p>
<?php endforeach ?>
</li>
<?php if (!$our_talentRecords): ?>
No records were found!<br/><br/>
<?php endif ?>
</ul>
</div>
Craig
KC Media Solutions
www.kcmedia.biz
Re: [kcmedia] Content to Show up only if there
By (Deleted User) - February 7, 2012
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
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 ?>
Craig
KC Media Solutions
www.kcmedia.biz
Re: [kcmedia] Content to Show up only if there
By (Deleted User) - February 8, 2012
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
no worries i worked it all out thanks.
Craig
KC Media Solutions
www.kcmedia.biz