Keyword

PHP if statement with image extra field

  • David Blane
  • David Blane's Avatar Topic Author
  • Offline
  • New Member
More
11 years 7 months ago - 11 years 7 months ago #110742 by David Blane
PHP if statement with image extra field was created by David Blane
I'm trying to display a <div> only if the image extra field is being used. if it is not being used, do not show the <div>

The code looks like this right now:
<?php if(isset($extrafields['3']) === true  && empty($extrafields['3']) === false): ?>
<div class="interview-image-block">
<?php echo $extrafields[3];?>
<div class="interview-caption">
<?php echo $extrafields[7];?>
</div>
</div>
<?php endif; ?>

The problem is the $extrafields variable is never empty it either displays

<img alt="Interviewer Image" src="/"> -- NO IMAGE

or

<img alt="Interviewer Image" src=".../image.png">
-- With An Image

So our PHP statement does not really do anything since the $extrafield variable is never empty.

How can I get this PHP code to work?

Thanks!

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

More
11 years 7 months ago #110743 by william white
Replied by william white on topic Re: PHP if statement with image extra field
You dont mention versions of j or k2.
If using newer version of k2 i would try using the syntax described in this blog post
getk2.org/blog/1068-k2-v262-now-available

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

  • David Blane
  • David Blane's Avatar Topic Author
  • Offline
  • New Member
More
11 years 7 months ago #110744 by David Blane
Replied by David Blane on topic Re: PHP if statement with image extra field
Apologies,
I am using K2 Version 2.6.5
and Joomla 2.5.9

Thanks for pointing me to the new syntax. That helps me for the most part.

Although, we would really like to be able to write the Extra Field ID Number and NOT the alias, if possible.

I have not been able to figure it out, what are your thoughts?

Thanks

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


Powered by Kunena Forum