Last active
May 20, 2017 18:20
-
-
Save xnau/4f19d08b7e240d81df2f1c5e2681b227 to your computer and use it in GitHub Desktop.
A single record template that shows a person's age.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* default template for displaying a single record | |
* | |
* This one calculates a person's age from a field named "birthdate" and shows it in a field named "age" | |
*/ | |
$record = new PDb_Template( $this ); | |
$date_field = 'birthdate'; | |
$age_field = 'age'; | |
?> | |
<div class="wrap <?php echo $this->wrap_class ?>"> | |
<?php while ( $this->have_groups() ) : $this->the_group(); ?> | |
<div class="section <?php $this->group->print_class() ?>" id="<?php echo Participants_Db::$prefix.$this->group->name ?>"> | |
<?php $this->group->print_title( '<h2 class="pdb-group-title">', '</h2>' ) ?> | |
<?php $this->group->print_description() ?> | |
<?php while ( $this->have_fields() ) : $this->the_field(); | |
// CSS class for empty fields | |
$empty_class = $this->get_empty_class( $this->field ); | |
if ( $this->field->name === $age_field ) { | |
$this->field->value = date('y') - date( 'y', $record->get_value( $date_field ) ); | |
} | |
?> | |
<dl class="<?php echo Participants_Db::$prefix.$this->field->name.' '.$this->field->form_element.' '.$empty_class?>"> | |
<dt class="<?php echo $this->field->name.' '.$empty_class?>"><?php $this->field->print_label() ?></dt> | |
<dd class="<?php echo $this->field->name.' '.$empty_class?>"><?php $this->field->print_value() ?></dd> | |
</dl> | |
<?php endwhile; // end of the fields loop ?> | |
</div> | |
<?php endwhile; // end of the groups loop ?> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment