Created
September 23, 2017 18:21
-
-
Save xnau/d4f255e3c46fa6e256620038a727c150 to your computer and use it in GitHub Desktop.
Demonstrates how to add the detail link to several fields in the Participants Database list display
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 | |
/* | |
* | |
* template for participants list shortcode output with adetail link on several fields | |
* | |
*/ | |
// define an array of field names to place the detail link on | |
$detail_link_fields = array( 'first_name','last_name','photo' ); | |
?> | |
<div class="wrap <?php echo $this->wrap_class ?>" id="<?php echo $this->list_anchor ?>"> | |
<?php | |
/* | |
* SEARCH/SORT FORM | |
* | |
* the search/sort form is only presented when enabled in the shortcode. | |
* | |
*/ | |
$this->show_search_sort_form(); | |
?> | |
<table class="wp-list-table widefat fixed pages list-container" > | |
<?php | |
// print the count if enabled in the shortcode | |
$this->print_list_count($wrap_tag = false); | |
?> | |
<?php if ( $record_count > 0 ) : // print only if there are records to show ?> | |
<thead> | |
<tr> | |
<?php $this->print_header_row( '<th class="%2$s" scope="col">%1$s</th>' ); ?> | |
</tr> | |
</thead> | |
<tbody> | |
<?php while ( $this->have_records() ) : $this->the_record(); // each record is one row ?> | |
<?php | |
// set up the template object for this record | |
$record = new PDb_Template($this); | |
?> | |
<tr> | |
<?php while( $this->have_fields() ) : $this->the_field(); // each field is one cell ?> | |
<td class="<?php echo $this->field->name ?>-field"> | |
<?php | |
/* | |
* put the detail link URL into the link property of the link field fields | |
*/ | |
if ( in_array( $this->field->name, $detail_link_fields ) { | |
$this->field->link = $record->get_detail_link(); | |
} | |
$this->field->print_value(); | |
?> | |
</td> | |
<?php endwhile; // each field ?> | |
</tr> | |
<?php endwhile; // each record ?> | |
</tbody> | |
<?php else : // if there are no records ?> | |
<tbody> | |
<tr> | |
<td><?php if ($this->is_search_result) echo Participants_Db::$plugin_options['no_records_message'] ?></td> | |
</tr> | |
</tbody> | |
<?php endif; // $record_count > 0 ?> | |
</table> | |
<?php | |
/* | |
* this shortcut function presents a pagination control with default layout | |
*/ | |
$this->show_pagination_control(); | |
?> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment