I would like to combine several fields (ie metadata) I created with texts in the show.php page.
The goal is to obtain, for example: “Birth: 1805 in New-York” where 1805 and “New-York” are two different metadata.
I achieved this goal with the following code.
<?php if ($meta = metadata('item', array('Item Type Metadata', 'Date of Birth'))): ?> <p>Birth: <?php echo $meta.' in '; ?> <?php if ($meta = metadata('item', array('Item Type Metadata', 'Place of Birth'))): ?> <?php echo ($meta).''; ?> </p> <?php endif; ?> <?php endif; ?>
But it is not very efficient and suppose to open a lot of
if. I have a lot of fields (~30) and it is not very convenient. Any idea to simply this code? I rather prefer to have something like:
A single if where $birthdate and $birthplace are verified as no null. If both fields have contents, then display: Birth: $birthdate in $birthplace