Display default value if field is left empty

6 posts by 3 authors in: Forums > CMS Builder
Last Post: November 28, 2011   (RSS)

Hello,

I have a WYSIWYG field for users to describe their listing, however it is not a required field and very often it is left blank.

Is there a way I can display a default value on the front-end website if the user does not type anything?

For example, if the the user doesn't type in a description then I can display at the front-end:

"For further details about this product please contact the advertiser...".

Thank you,
Greg

Re: [zip222] Display default value if field is left empty

Hi,

Thanks for the reply. I'd like to do this on a detail page.

How does the code change?

Thanks again,
Greg

Re: [gversion] Display default value if field is left empty

Hi,

Do you know why this code isn't working?

if(!$listingsRecord['list_price']) { 
echo "<p>No price specified</p>"; 

else
echo "<? php $listingsRecord['currency']?> <? php $listingsRecord['list_price'] ?>";
?>

Thank for you help!

Greg

Re: [gversion] Display default value if field is left empty

By Jason - November 27, 2011

Hi Greg,

You're not going to need the <?php tags inside your string, since you're already in a PHP block,

try this:

<?php
if(!$listingsRecord['list_price']) {
echo "<p>No price specified</p>";
}
else {
echo $listingsRecord['currency'].$listingsRecord['list_price'];
}
?>


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] Display default value if field is left empty

Hi Jason,

Thanks for the help. It was the concatenation symbol I needed to know about!

Regards,
Greg