Skip to content

Instantly share code, notes, and snippets.

@xnau
Last active May 15, 2017 18:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xnau/db7b28fb8be3a1fc7246892e7b81a47d to your computer and use it in GitHub Desktop.
Save xnau/db7b28fb8be3a1fc7246892e7b81a47d to your computer and use it in GitHub Desktop.
example of a single template with tabs and excluded groups
<?php
/*
* example of a single template with tabs and excluded groups
*
*
*/
// first establish the set og group to show for this record type
if ( $this->participant_values['type'] == 'customer' ) {
$allowed_groups = array( 'main', 'address', 'personal' );
} else {
$allowed_groups = array( 'main', 'address' );
}
// get the main template object
$record = new PDb_Template($this);
// remove the groups that are to be skipped
foreach ( $record->groups as $group ) {
if ( ! in_array( $group->name, $allowed_groups ) ) {
unset ( $record->groups[$group] );
}
}
global $PDb_Field_Group_Tabs;
// use the template object to set up the tabs
$tab_control = $PDb_Field_Group_Tabs->get_tab_control($record);
?>
<div class="wrap <?php echo $this->wrap_class ?>">
<?php echo $tab_control ?>
<?php while ( $this->have_groups() ) : $this->the_group(); ?>
<?php // only show the group if it's on the liat
if ( in_array( $this->group->name, $allowed_groups ) ) : ?>
<section id="<?php echo Participants_Db::$prefix.$this->group->name?>" class="<?php $this->group->print_class() ?> field-group" style="overflow:auto">
<?php $this->group->print_title( '<h2 class="field-group-title">', '</h2>' ) ?>
<?php $this->group->print_description( '<p>', '</p>' ) ?>
<?php
while ( $this->have_fields() ) : $this->the_field();
// CSS class for empty fields
$empty_class = $this->get_empty_class( $this->field );
?>
<dl class="dl-horizontal <?php echo Participants_Db::$prefix.$this->field->name ?>">
<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 ?>
</section>
<?php endif; 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