Calendar "More info" link hide

Hello,

I have added in the blueprint a More info field with link.
But when the field is empty, it show the link but the href is empty.

echo '<a href="'.$event->getField("link").'" target="_blank">More info</a>';

How can I hide the whole line when it’s empty?

Thx for helping.

<?php
	$tmpDate = getdate(0);
	$currentDate = getdate();
?>
<div class="calendar">
	<?php if (!$calendar->getAllEvents()): echo l::get('calendar-no-entry'); else: ?>
	<?php foreach ($calendar->getAllEvents() as $event): $date = $event->getBeginDate(); ?>
	<ul>
		<li>
			<strong><?php echo $event->getBeginHtml(); ?> : </strong>
			<?php
				echo $event->getField("summary");
				echo '<br />'.$event->getField("description").' ';
				echo '<a href="'.$event->getField("link").'" target="_blank">More info</a>';
			?>
		</li>
	</ul>
	<?php $tmpDate = $date; ?>
	<?php endforeach; ?>
	<?php endif; ?>
</div>

What are all these getAllEvents and getField methods? Have you defined these in a model?

Getting a field generally works like this:

<?php if(!$event->link()->empty()): ?>
  <a href="<?php echo $event->link() ?>" target="_blank">More info</a>
<?php endif ?>

I assume you are using the calendar plugin? You can do something like this:

<?php if (($link = $event->getField("link")) !== ''): ?>
   <a href="<?php echo $link ?>" target="_blank">More info</a>
<?php endif ?>