Jump to content

is is possible individual field setting for different template ?


Recommended Posts

Posted

i have an image field.

A template accept one image file  upload

Another template has no number of image file limitation

Instead of create two different image field of different field setting,  is there any module add field extend to allow individual field settings for different template ?

Posted (edited)
if($page->template == 'one-image-template') {
	if(!count($page->multi_image_field)) {
		// add image, none added yet	
	}
}
else {
	// add as many images as you like
}

 

Edited by kongondo
clearer code
Posted
8 minutes ago, kongondo said:

if($page->template == 'one-image-template') {
	if(!count($page->multi_image_field))// add image, none added yet	
}
else {
	// add as many images as you like
}

 

what is the purpose of the second if statement ?

Posted (edited)

Checks if you already have an image in that image field. If count returns something, it means there's an image in the field already. It presupposes you've never added more than one image before. If its empty, you can add an image, if not empty, do something else.  This is near-pseudo code so things can be changed around...Edited the code above for clarity

Edited by kongondo
clarity...
  • Like 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...