php code to display a field if it exists

More
14 years 1 month ago #10674 by intown
This is probably a simple php question but I am not sure how to create the code.

What code is required to some text if a field exists?

I know how to do it if a position contains info.
Code:
<?php if (isset($this->item->positions['NAME'])) : ?>display some text<?php endif; ?>

just not sure how to write the code for a specific field.

Any suggestions?

Please Log in or Create an account to join the conversation.

More
14 years 1 month ago #10675 by yopyop001
Hi,

May be using :
Code:
if(isset($this->fields['FIELD_NAME']->value)): .... endif;

Regards

Please Log in or Create an account to join the conversation.

More
14 years 1 month ago #10676 by intown
thanks so much for the reply.

I added the code but the text is still continuing to be displayed if the the field has a value or not. what if I added something like !='' to the statement
Code:
if(isset($this->fields['FIELD_NAME']->value) !='') :

I tried this statement but it did not work, perhaps some variation of this?

Thanks!

Please Log in or Create an account to join the conversation.

More
14 years 1 month ago #10677 by yopyop001
Hi,

And just with :
Code:
if($this->fields['FIELD_NAME']->value !='') :

or
Code:
if($this->fields['FIELD_NAME']->display !='') :

Please Log in or Create an account to join the conversation.

More
14 years 1 month ago #10678 by intown
Thanks so much!
Code:
if($this->fields['FIELD_NAME']->display !='') :

Was the code that displays a field if it exists

Thanks again!

Please Log in or Create an account to join the conversation.

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.312 seconds
Save
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Display
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline