Keyword

PHP statement for "no item image"

  • Andrew Paterson
  • Andrew Paterson's Avatar Topic Author
  • Offline
  • Junior Member
More
10 years 1 month ago #131381 by Andrew Paterson
PHP statement for "no item image" was created by Andrew Paterson
Greetings

In a K2 template override-

where this code will check if an item does have an image:

<?php if($this->item->params->get('catItemImage') && !empty($this->item->image)): ?>

is there a way to specifically check if the item does not have an image?

I'd like to add a class to a certain element if the item does not have an image, as this will make templating much easier.

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

More
10 years 1 month ago #131382 by JoomlaWorks
Replied by JoomlaWorks on topic Re: PHP statement for "no item image"
Is this HTML element you wish to style within K2's sub-templates?

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

  • Andrew Paterson
  • Andrew Paterson's Avatar Topic Author
  • Offline
  • Junior Member
More
10 years 1 month ago #131383 by Andrew Paterson
Replied by Andrew Paterson on topic Re: PHP statement for "no item image"
Yes it is-

I'd like to be able to add a class to the html container if no image is saved with the item. (I've done it successfully to add a class if the item does have an image- I just wanted to see if it could work the other way).

Many thanks

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
10 years 1 month ago #131384 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: PHP statement for "no item image"
Something like this will do the trick.
<div class="<?php if($this->item->params->get('catItemImage') && !empty($this->item->image)): ?>no-image<?php else:?>has-image<?php endif; ?>"></div>

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

  • Andrew Paterson
  • Andrew Paterson's Avatar Topic Author
  • Offline
  • Junior Member
More
10 years 2 weeks ago #131385 by Andrew Paterson
Replied by Andrew Paterson on topic Re: PHP statement for "no item image"
Thanks very much- this works great! Only thing is I think that the two classes need to be switched-

I'm using this:
Log in  or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
10 years 2 weeks ago #131386 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: PHP statement for "no item image"
You 're welcome Andrew.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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