Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Shows how to use the PDb_Template class in a custom list template
<?php
/*
template for participants list shortcode output demonstrating a directory-style responsive layout
this template demonstrates a "table-less" reponsive layout for the list of records
*/
?>
<div class="wrap <?php echo $this->wrap_class ?>" id="<?php echo $this->list_anchor ?>">
<?php /* SEARCH/SORT FORM */ ?>
<?php if ( $filter_mode != 'none' ) : ?>
<div class="pdb-searchform">
<div class="alert alert-block" style="display:none">
<a class="close" data-dismiss="alert" href="#">X</a>
<p class="search_field_error"><?php _e( 'Please select a column to search in.', 'participants-database' )?></p>
<p class="value_error"><?php _e( 'Please type in something to search for.', 'participants-database' )?></p>
</div>
<?php $this->search_sort_form_top( false, 'form-horizontal' ); ?>
<?php if ( $filter_mode == 'filter' || $filter_mode == 'both' ) : ?>
<div class="control-group">
<label class="control-label"><?php _e('Search', 'participants-database' )?>:</label>
<div class="controls">
<?php $this->column_selector( false ); // selects the field to search on ?>
<?php $this->search_form() ?>
</div>
</div>
<?php endif ?>
<?php if ( $filter_mode == 'sort' || $filter_mode == 'both' ) : ?>
<div class="control-group">
<label class="control-label"><?php _e('Sort by', 'participants-database' )?>:</label>
<div class="controls">
<?php $this->sort_form() ?>
</div>
</div>
<?php endif ?>
</div>
<?php endif ?>
<?php // this is an example of a way to style the records, delete this or edit as needed ?>
<style type="text/css">
section {
margin: 1.5em 0;
}
.pdb-field-title {
font-weight: bold;
padding-right: 15px;
}
.pdb-field-title:after {
content: ':';
}
</style>
<div class="pdb-list list-container" >
<?php $this->print_list_count('<h5>'); ?>
<?php if ( $record_count > 0 ) : ?>
<?php while ( $this->have_records() ) : $this->the_record(); // each record is one row ?>
<section class="company-listing" id="record-<?php echo $this->record->record_id ?>">
<?php // the template class is instantiated for each record here
$company = new PDb_Template( $this ); ?>
<h2 class="business-title"><?php $company->print_field('company') ?></h2>
<p class="company-contact">Contact: <?php $company->print_field('contact_name') ?> <?php $company->print_field('phone') ?> <?php $company->print_field('email') ?></p>
<p class="website"><?php $company->print_field('website') ?></p>
</section>
<?php endwhile; // each record ?>
<?php else : // if there are no records ?>
<h4><?php if ($this->is_search_result === true) echo Participants_Db::$plugin_options['no_records_message'] ?></h4>
<?php endif; // $record_count > 0 ?>
</div>
<?php
$this->pagination->set_current_page_class( 'active' );
// wrap the current page indicator with a dummy anchor
$this->pagination->set_anchor_wrap( false );
$this->pagination->set_props(array( 'list_class' => '', ));
$this->pagination->show();
?>
</div>
@chavezcr27

This comment has been minimized.

Copy link

@chavezcr27 chavezcr27 commented Jun 24, 2017

Is perfect

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment