Simple PHP question


Currently I am trying to learn PHP and build a Kirby site. I am making steady progress but sometimes you get stuck. Like this moment.
It is probably a very simple question, but I can not figure it out. Can someone help me?

I have this but I’m sure this is overkill. I run ‘if’ ‘endif’ 3 times. How can I solve this. I know it has to do something with If, Or, Else etc. I searched already on the internet/forum but I didn’t managed it.

		<div class="row">
			<div class="col-sm-12 text-center">
				<ul class="list-inline social-list wide">
		<?php if ($data->twitter()->isNotEmpty()): ?>
					<li><a href="<?= $data->twitter() ?>"target="_blank"><i class="icon icon-sm ti-twitter-alt"></i></a></li>
		<?php endif ?>
		<?php if ($data->facebook()->isNotEmpty()): ?>
					<li><a href="<?= $data->facebook() ?>"target="_blank"><i class="icon icon-sm ti-facebook"></i></a></li>
		<?php endif ?>
		<?php if ($data->instagram()->isNotEmpty()): ?>			
					<li><a href="<?= $data->instagram() ?>"target="_blank"><i class="icon icon-sm ti-instagram"></i></a></li>
		<?php endif ?>
		</div><!--end of row-->


No, that’s perfectly alright.

To avoid that, you could use a different data structure, for example, a structure field instead of multiple different fields.

1 Like

Thank you! I really appreciate the quick response :slight_smile: