GravityView  2.17
The best, easiest way to display Gravity Forms entries on your website.
entries/list.php
Go to the documentation of this file.
1 <?php
2 /**
3  * Display a single entry when using a list template
4  *
5  * @global \GV\Template_Context $gravityview
6  */
7 
8 if ( ! isset( $gravityview ) || empty( $gravityview->template ) ) {
9  gravityview()->log->error( '{file} template loaded without context', array( 'file' => __FILE__ ) );
10  return;
11 }
12 
13 $entry = $gravityview->entry;
14 
15 \GV\Mocks\Legacy_Context::push( array( 'view' => $gravityview->view ) );
16 
18 
19 extract( $gravityview->template->extract_zone_vars( array( 'title', 'subtitle' ) ) );
20 extract( $gravityview->template->extract_zone_vars( array( 'image', 'description', 'content-attributes' ) ) );
21 extract( $gravityview->template->extract_zone_vars( array( 'footer-left', 'footer-right' ) ) );
22 
23 gravityview_before( $gravityview );
24 
25 ?><div class="<?php gv_container_class( 'gv-list-container gv-list-single-container', true, $gravityview ); ?>">
26 
27  <?php if ( $link = gravityview_back_link( $gravityview ) ) { ?><p class="gv-back-link"><?php echo $link; ?></p><?php } ?>
28 
29  <?php if ( $has_title || $has_subtitle || $has_image || $has_description || $has_content_attributes || $has_footer_left || $has_footer_right ): ?>
30  <div id="gv_list_<?php echo esc_attr( $entry_slug ); ?>" class="gv-list-view">
31 
32  <?php if ( $has_title || $has_subtitle ) { ?>
33 
34  <div class="gv-list-view-title">
35 
36  <?php
37  $did_main = 0;
38  foreach ( $title->all() as $i => $field ) {
39  // The first field in the title zone is the main
40  if ( $did_main == 0 ) {
41  $did_main = 1;
42  $extras = array( 'wpautop' => false, 'markup' => '<h3 class="{{ class }}">{{ label }}{{ value }}</h3>' );
43  } else {
44  $extras = array( 'wpautop' => true );
45  }
46 
47  $extras['zone_id'] = 'single_list-title';
48  echo $gravityview->template->the_field( $field, $extras );
49  }
50 
51  if ( $has_subtitle ) {
52  ?><div class="gv-list-view-subtitle"><?php
53  $did_main = 0;
54  foreach ( $subtitle->all() as $i => $field ) {
55  // The first field in the subtitle zone is the main
56  if ( $did_main == 0 ) {
57  $did_main = 1;
58  $extras = array( 'markup' => '<h4 id="{{ field_id }}" class="{{ class }}">{{ label }}{{ value }}</h4>' );
59  }
60 
61  $extras['zone_id'] = 'single_list-subtitle';
62  echo $gravityview->template->the_field( $field, $extras );
63  }
64  ?></div><?php
65  }
66  ?>
67  </div>
68  <?php }
69 
70  if ( $has_image || $has_description || $has_content_attributes ) {
71  ?>
72  <div class="gv-list-view-content">
73 
74  <?php
75  if ( $has_image ) {
76  ?><div class="gv-list-view-content-image gv-grid-col-1-3"><?php
77  foreach ( $image->all() as $i => $field ) {
78  echo $gravityview->template->the_field( $field, array( 'zone_id' => 'single_list-image' ) );
79  }
80  ?></div><?php
81  }
82 
83  if ( $has_description ) {
84  ?><div class="gv-list-view-content-description"><?php
85  $extras = array( 'label_tag' => 'h4', 'wpautop' => true );
86  foreach ( $description->all() as $i => $field ) {
87  $extras = array( 'wpautop' => true, 'zone_id' => 'single_list-description', 'label_markup' => '<h4>{{ label }}</h4>' );
88  echo $gravityview->template->the_field( $field, $extras );
89  }
90  ?></div><?php
91  }
92 
93  if ( $has_content_attributes ) {
94  ?><div class="gv-list-view-content-attributes"><?php
95  $extras = array( 'label_tag' => 'h4', 'wpautop' => true );
96  foreach ( $attributes->all() as $i => $field ) {
97  $extras = array( 'zone_id' => 'single_list-content-attributes', 'markup' => '<p id="{{ field_id }}" class="{{ class }}">{{ label }}{{ value }}</p>' );
98  echo $gravityview->template->the_field( $field, $extras );
99  }
100  ?></div><?php
101  }
102  ?>
103 
104  </div>
105 
106  <?php
107  }
108 
109  // Is the footer configured?
110  if ( $has_footer_left || $has_footer_right ) {
111  ?>
112 
113  <div class="gv-grid gv-list-view-footer">
114  <div class="gv-grid-col-1-2 gv-left">
115  <?php
116  foreach ( $footer_left->all() as $i => $field ) {
117  echo $gravityview->template->the_field( $field, array( 'zone_id' => 'single_list-footer-left' ) );
118  }
119  ?>
120  </div>
121 
122  <div class="gv-grid-col-1-2 gv-right">
123  <?php
124  foreach ( $footer_right->all() as $i => $field ) {
125  echo $gravityview->template->the_field( $field, array( 'zone_id' => 'directory_list-footer-right' ) );
126  }
127  ?>
128  </div>
129  </div>
130 
131  <?php
132  } // End if footer is configured
133 
134  ?>
135  </div>
136  <?php endif; ?>
137 </div><?php
138 
139 gravityview_after( $gravityview );
140 
$image
Definition: post_image.php:98
if( $has_title|| $has_subtitle) if( $has_image|| $has_description|| $has_content_attributes) if( $has_footer_left|| $has_footer_right) endif
gravityview_after()
Definition: class-api.php:1274
$entry_slug
if( $add_query_args) $link
if(! isset( $gravityview)||empty( $gravityview->template)) $entry
Display a single entry when using a list template.
gravityview_back_link( $context=null)
Generate HTML for the back link from single entry view.
Definition: class-api.php:953
static pop()
Restores last saved state and context.
Definition: _mocks.php:410
static push( $configuration)
Set the state depending on the provided configuration.
Definition: _mocks.php:400
static get_entry_slug( $id_or_string, $entry=array())
Get the entry slug for the entry.
Definition: class-api.php:550
gravityview()
The main GravityView wrapper function.
gravityview_before()
Definition: class-api.php:1187
$description
Definition: post_image.php:28
$title