Return to Snippet

Revision: 32618
at September 30, 2010 16:07 by juggernaut


Initial Code
<?php /* we're using php comments to make sure it is commented completely! this is the code snippet to assign the extra fields array to the variable called $custom */ ?>

	<?php $custom = $this->item->extra_fields; ?>

<?php /* this is the if statement to show a block of code only if the first custom field is not empty */ ?>

	<?php if(!empty($custom[0]->value)):?>
		
This is the code or text to show only if the first custom field is not empty. To actually output the field in here, you would add it like this:
		
<?php echo $custom[0]->value;?>
	<?php endif;?>

<?php /* to make this work for any other field, just change the number in the [square brackets]. the first field in the group is 0, second is 1, third is 2, etc. */ ?>

Initial URL


Initial Description


Initial Title
Add code to k2 page dependant upon extra field value 0/1

Initial Tags
joomla

Initial Language
PHP