Jump to content

Optional Database Field Template View

Featured Replies

Posted

So I've got several fields in my database that I'm not requiring my staff to fill out. So it's an optional database field, essentially. 

When it comes to displaying this on the front end - can someone tell me the "Custom Display Format" that would hide this field if nothing is filled in. Then display the field if the staff member had put content into that optional database field.

Thanks! 

{{if $formValue}}

{{endif}}

 

  • Author

Thanks!!

  • Author
18 minutes ago, opentype said:

{{if $formValue}}

{{endif}}

 

Though this does seem to work - it still leaves a space (<br>) even though there is no data displayed. Is there a way to eliminate it?

Probably, but hard to say where this is coming from without looking at all the involved templates and settings. 

  • Author
{$record->customFieldDisplayByKey('2015', 'display')|raw}
    <br>
{$record->customFieldDisplayByKey('2014', 'display')|raw}
    <br>
{$record->customFieldDisplayByKey('2013', 'display')|raw}
    <br>
{$record->customFieldDisplayByKey('2012', 'display')|raw}
    <br>
{$record->customFieldDisplayByKey('2011', 'display')|raw}

This is what I have showing on the template ^^^

Then below is what I have on the "Display Custom Format" inside the database field settings...

{{if $formValue}}<b>{$label}:</b> {$value}{{endif}}                   - this is the same for each field listed above, (2015, 2014, 2013, 2012, 2011)

Oh, I see. You put the break in there yourself! ;-)

Just make it part of the IF statement then, e.g. 

{{if $formValue}}<b>{$label}:</b> {$value}<br>{{endif}}

 

  • Author

That makes too much sense. Thanks @opentype - definitely nice to have a second eye on things. 

Archived

This topic is now archived and is closed to further replies.

Recently Browsing 0

  • No registered users viewing this page.