Reputation: 1205
I am using Kirby for my CMS. I setup a custom field and when I have nothing inside it, it still outputs a blank line.
Backend screenshot showing no field value: http://cloud.chrisburton.me/LSyR
View Source showing blank line (52): http://cloud.chrisburton.me/LSW0
My Code:
<ul class="credits">
<?php
if($page->client() != '')
echo '<li><span>Client: </span>'.$page->client().'</li>';
?>
<?php
if($page->art_direction() != '')
echo '<li><span>Client: </span>'.$page->art_direcion().'</li>';
?>
<?php
if($page->typeface() != '')
echo '<li><span>Typeface: </span>'.$page->typeface().'</li>';
?>
</ul>
How can I remove that?
Upvotes: 0
Views: 132
Reputation: 19380
WYSIWYG.
I'd suggest different approach...
<ul class="credits">
<?php
foreach(array('Client' => $page->client(), 'Direction' => $page->art_direction(), 'Typeface' => $page->typeface()) as $key => $value)
if($value != '') echo "\t<li><span>{$key}: </span>{$value}</li>\n";
?>
</ul>
Also, make sure you don't indent <?php
and that it starts from position 0.
Upvotes: 2
Reputation: 15981
<ul class="credits">
<?php
if($page->client() != '')
echo '<li><span>Client: </span>'.$page->client().'</li>';
if($page->art_direction() != '')
echo '<li><span>Client: </span>'.$page->art_direcion().'</li>';
if($page->typeface() != '')
echo '<li><span>Typeface: </span>'.$page->typeface().'</li>';
?>
</ul>
Upvotes: 1