Home | Products | Consulting | Forums | Support | Order | 1-800-752-0455
  Main
Index
Search
Posts
Who's
Online
Log
In

Home: Products: CMS Builder:
Making a field only appear if it has data

 

 


_kate_
User


Jun 8, 2008, 9:22 AM

Post #1 of 4 (184 views)
Shortcut
Making a field only appear if it has data Can't Post

I am making an online portfolio. I want to have links to previews of pages. I made 3 textfields as each project would have at most 3 links to preview pages.

Some projects will have no links, some 1 others 3 etc. How can I get this information to only display when it has data in that field? I am trying to get a display something like the below >

View: <a href="<?php echo $record['store'] ?>" target="_blank">Store Front</a>, <a href="<?php echo $record['auction'] ?>" target="_blank">Auction Template</a>


sagentic
User


Jun 8, 2008, 9:40 AM

Post #2 of 4 (182 views)
Shortcut
Re: [AgentBristow] Making a field only appear if it has data [In reply to] Can't Post

For each link you could use:

<?php if ($record['store']): ?><a href="<?php echo $record['store'] ?>" target="_blank">Store Front</a><?php endif ?>

<?php if ($record['auction']): ?><a href="<?php echo $record['auction'] ?>" target="_blank">Auction Template</a><?php endif ?>


_kate_
User


Jun 8, 2008, 9:57 AM

Post #3 of 4 (180 views)
Shortcut
Re: [sagentic] Making a field only appear if it has data [In reply to] Can't Post

Cool, thanks that works well. I'm using the below code >

<?php if ($record['store']): ?>View: <?php endif ?>

<?php if ($record['store']): ?><a href="<?php echo $record['store'] ?>" target="_blank">Store Front</a><?php endif ?>
<?php if ($record['auction']): ?><a href="<?php echo $record['auction'] ?>" target="_blank">Auction Template</a><?php endif ?>


Sometimes I may only have the Auction Template link, and with the above code in this form the word "View" wouldn't display if there was only an auction link. How can I edit the code so that it shows "View" if the record is "store" OR "auction"?

Also, if there is more than one link showing, is there anyway to get it to display a comma after each record (except the last one)?

Thanks :)


Dave
Staff / Moderator


Jun 9, 2008, 11:34 AM

Post #4 of 4 (166 views)
Shortcut
Re: [AgentBristow] Making a field only appear if it has data [In reply to] Can't Post

Hi AgentBristow,

You can use " or " like this to test on more than one condition:

<?php if ($record['store'] or $record['auction']): ?>
View:
<?php endif ?>

And if you only had two links, you could use the same if statement to print a comma in the middle if both were defined. Will that work for you?

Dave Edis - Senior Developer
interactivetools.com

 
 
 


Search for (options)
Products
CMS Builder
Article Manager
Realty Manager
Listings Manager
Order Now
Services
Priority Consulting
Support
Online Documentation
Support Forums
Support Homepage
Company Info
12 reasons to choose us!
Meet the team
Monthly newsletter
Contact Us
Toll Free: 1-800-752-0455
Phone: (604) 689-3347
Sales | Support
Conditions of Use | Privacy Policy | Copyright © interactivetools.com 2008
#201 - 2730 Commercial Drive, Vancouver BC Canada V5N 5P4