- Posts: 36
 
COMMUNITY FORUM
PHP statement for "no item image"
- Andrew Paterson
 - 
				
Topic Author
 - Offline
 - Junior Member
 
		Less
		More
		
			
	
		
			
	
						11 years 2 months 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.
					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.
- JoomlaWorks
 - 
				
 - Offline
 - Admin
 
		Less
		More
		
			
	
		- Posts: 6229
 
			
	
						11 years 2 months 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?			
					Please Log in or Create an account to join the conversation.
- Andrew Paterson
 - 
				
Topic Author
 - Offline
 - Junior Member
 
		Less
		More
		
			
	
		- Posts: 36
 
			
	
						11 years 2 months 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
					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
 - 
				
 - Offline
 - Platinum Member
 
		Less
		More
		
			
	
		- Posts: 15920
 
			
	
						11 years 2 months 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>Please Log in or Create an account to join the conversation.
- Andrew Paterson
 - 
				
Topic Author
 - Offline
 - Junior Member
 
		Less
		More
		
			
	
		- Posts: 36
 
			
	
						11 years 1 month 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:
	
	I'm using this:
Log in  or Create an account to join the conversation.
	
		
			 		
													- Krikor Boghossian
 - 
				
 - Offline
 - Platinum Member
 
		Less
		More
		
			
	
		- Posts: 15920
 
			
	
						11 years 1 month ago				#131386
		by Krikor Boghossian
	
	
		
			
	
			
			 		
													
	
				Replied by Krikor Boghossian on topic Re: PHP statement for "no item image"			
			
				You 're welcome Andrew.			
					Please Log in or Create an account to join the conversation.