Last active
March 16, 2017 01:13
-
-
Save xnau/d7062e95ffc7bcba0487d3c5711982c2 to your computer and use it in GitHub Desktop.
demonstrates adding an edit link to s single record page
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 is the new "WordPress style" template | |
* | |
* each group with the "visible" attribute checked will display its fields in the order set | |
* in the manage database fields page. | |
* | |
* if there are specific fields you wish to exclude from display, you can include the "name" value of | |
* the field in the $exclude array like this: $exclude = array( 'city','state','country' ); or whatever | |
* you want. Leave it empty (like it is here) if you don't want to exclude any fields. | |
* | |
* this template is a simple demonstration of what is possible | |
* | |
* for those unfamiliar with PHP, just remember that something like <?php echo $group->name ?> just prints out | |
* the group name. You can move it around, but leave all the parts between the <> brackets as they are. | |
* | |
*/ | |
// define an array of fields to exclude here | |
$exclude = array(); | |
?> | |
<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(); | |
// skip any field found in the exclude array | |
if ( in_array( $this->field->name, $exclude ) ) continue; | |
// CSS class for empty fields | |
$empty_class = $this->get_empty_class( $this->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 ?> | |
<?php | |
// create a template object so we can get the edit link URL | |
$record = new PDb_Template( $this ); | |
// now output the link using the get_edit_link method | |
?> | |
<p><a href="<?php echo $record->get_edit_link() ?>">Edit Link</a></p> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment