UPDATES EasyBlog 6.0.14 Released! Joomla 5.x and PHP 8.x compatible now!

Helpdesk

Your Time
Our Time
Response Time
24 — 48 hours
We strive to provide the fastest ever response possible. However, we are not super beings.

Allow at least 24 — 48 hours
  Support is offline
It is currently off working hours and most of us aren't around

Rest assured that we will get back to you as soon as the day starts tomorrow!
  Support is offline

How to check if field have value

Mist · ·
7:41 PM Monday, 27 July 2015
None
Hi guys, i am trying to output some user profile fields value in joomla article.
What i need is to build an "if" statement that will output the code only if the field have a value.

What i did so far

1. I am getting the author ID of the article like this

$authorid = $this->item->created_by ? $this->item->created_by : $this->item->author;


2. I am setting-up variables for the fields i need

//Author Extended Profile Info
$author_city = Foundry::user($authorid)->getFieldValue('ADDRESS')->value->city;
$author_state = Foundry::user($authorid)->getFieldValue('ADDRESS')->value->state;
$author_about = Foundry::user($authorid)->getFieldValue('ABOUT');
$user_website = Foundry::user($authorid)->getFieldValue('URL');


3. Now, finally, i am trying to "output" those fields ONLY if the field have value ... but it doesn't work

 <?php if( $author_about ){ ?>
<?php echo $author_about;?>
<?php } ?>


<?php if( $user_website ){ ?>
<a href="http://<?php echo $user_website; ?>/" rel="nofollow" target="_blank"><?php echo $user_website; ?></a>
<?php } ?>


... and so on

How to build that "if" statement in order to output the field only if it contains value ?

Thanks !
The replies under this section are restricted to logged in users or users with an active subscription with us