Keyword

Empty Fields. Need some php adapting

  • xtreme07
  • xtreme07's Avatar Topic Author
  • Offline
  • New Member
More
13 years 6 months ago #95413 by xtreme07
Empty Fields. Need some php adapting was created by xtreme07
Hi

 

i need some adapting to chech for empty fields to my lines. asking for help as i ain't a php programmer and need some fast tweaking.

 

my code lines are

<?php

foreach ($this->item->extra_fields as $key=>$extraField):
switch ($extraField->id) {

case 11:
$textfield = $extraField->value;
break;

case 12:
$textarea = $extraField->value;
break;

case 13:
$link = $extraField->value;
break;

}

endforeach;

?>

<div style="width: 150px; float: left; background-color:#FF6;">
<?php echo $textfield; ?>
</div>

<div style="width: 150px; float: left; background-color:#FF6;">
<?php echo $textarea; ?>
</div>

<div style="width: 150px; float: left; background-color:#FF6;">
<?php echo $link; ?>
</div>

 

before it prints the output for each of the cases textfield, textarea and link, i need k2 to check if the fields are empty and only print the results if the fields are filled.

 

i've found some stuff on this empty thing but i amgetting errors cause i ain't that good at adapting the stuff to my code. so, i'd appreciate some help here.

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

  • Yiota
  • Yiota's Avatar
  • Visitor
13 years 6 months ago #95414 by Yiota
Replied by Yiota on topic Empty Fields. Need some php adapting
Try to make an if statement with the condition (!empty($extraField->value;))

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

More
13 years 1 month ago #95415 by Bjern Potgieter
Replied by Bjern Potgieter on topic Empty Fields. Need some php adapting
Hiding extra fields and checking for blanks can be done like this in 2 lines of code (see tutorial):

 

Hiding K2 extra fields

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


Powered by Kunena Forum