GravityView  2.10.1
The best, easiest way to display Gravity Forms entries on your website.
views/list/list-body.php
Go to the documentation of this file.
1 <?php
2 /**
3  * The entry loop for the list output.
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 $template = $gravityview->template;
14 
15 /** @action `gravityview/template/list/body/before` */
16 $template::body_before( $gravityview );
17 
18 // There are no entries.
19 if ( ! $gravityview->entries->count() ) {
20  ?>
21  <div class="gv-list-view gv-no-results">
22  <div class="gv-list-view-title">
23  <h3><?php echo gv_no_results( true, $gravityview ); ?></h3>
24  </div>
25  </div>
26  <?php
27 } else {
28  // There are entries. Loop through them.
29  foreach ( $gravityview->entries->all() as $entry ) {
30 
32 
33  /** @filter `gravityview/template/list/entry/class` */
34  $entry_class = $template::entry_class( 'gv-list-view', $entry, $gravityview );
35 
36  ?>
37  <div id="gv_list_<?php echo esc_attr( $entry_slug ); ?>" class="<?php echo gravityview_sanitize_html_class( $entry_class ); ?>">
38 
39  <?php
40 
41  /** @action `gravityview/template/list/entry/before` */
42  $template::entry_before( $entry, $gravityview );
43 
44  /**
45  * @var bool $has_title
46  * @var bool $has_subtitle
47  * @var \GV\Field_Collection $title
48  * @var \GV\Field_Collection $subtitle
49  */
50  extract( $template->extract_zone_vars( array( 'title', 'subtitle' ) ) );
51 
52  if ( $has_title || $has_subtitle ) {
53 
54  /** @action `gravityview/template/list/entry/title/before` */
55  $template::entry_before( $entry, $gravityview, 'title' );
56 
57  ?>
58 
59  <div class="gv-list-view-title">
60  <?php
61  $did_main = 0;
62  foreach ( $title->all() as $i => $field ) {
63  // The first field in the title zone is the main
64  if ( $did_main == 0 ) {
65  $did_main = 1;
66  $extras = array( 'wpautop' => false, 'markup' => '<h3 class="{{ class }}">{{ label }}{{ value }}</h3>' );
67  } else {
68  $extras = array( 'wpautop' => true );
69  }
70 
71  $extras['zone_id'] = 'directory_list-title';
72  echo $gravityview->template->the_field( $field, $entry, $extras );
73  }
74 
75  if ( $has_subtitle ) {
76  ?><div class="gv-list-view-subtitle"><?php
77  $did_main = 0;
78  foreach ( $subtitle->all() as $i => $field ) {
79  // The first field in the subtitle zone is the main
80  if ( $did_main == 0 ) {
81  $did_main = 1;
82  $extras = array( 'markup' => '<h4 id="{{ field_id }}" class="{{ class }}">{{ label }}{{ value }}</h4>' );
83  }
84 
85  $extras['zone_id'] = 'directory_list-subtitle';
86  echo $gravityview->template->the_field( $field, $entry, $extras );
87  }
88  ?></div><?php
89  }
90  ?>
91  </div>
92  <?php
93 
94  /** @action `gravityview/template/list/entry/title/after` */
95  $template::entry_after( $entry, $gravityview, 'title' );
96 
97  }
98 
99  /**
100  * @var bool $has_image
101  * @var bool $has_description
102  * @var bool $has_content_attributes
103  * @var \GV\Field_Collection $image
104  * @var \GV\Field_Collection $description
105  * @var \GV\Field_Collection $attributes
106  */
107  extract( $template->extract_zone_vars( array( 'image', 'description', 'content-attributes' ) ) );
108 
109  $has_content_before_action = has_action( 'gravityview/template/list/entry/content/before' );
110  $has_content_after_action = has_action( 'gravityview/template/list/entry/content/after' );
111 
112  if ( $has_image || $has_description || $has_content_attributes || $has_content_before_action || $has_content_after_action ) {
113  ?>
114  <div class="gv-grid gv-list-view-content">
115 
116  <?php
117 
118  /** @action `gravityview/template/list/entry/content/before` */
119  $template::entry_before( $entry, $gravityview, 'content' );
120 
121  if ( $has_image ) {
122  ?><div class="gv-grid-col-1-3 gv-list-view-content-image"><?php
123  foreach ( $image->all() as $i => $field ) {
124  echo $gravityview->template->the_field( $field, $entry, array( 'zone_id' => 'directory_list-image' ) );
125  }
126  ?></div><?php
127  }
128 
129  if ( $has_description ) {
130  ?><div class="gv-grid-col-2-3 gv-list-view-content-description"><?php
131  foreach ( $description->all() as $i => $field ) {
132  $extras = array( 'wpautop' => true, 'zone_id' => 'directory_list-description', 'label_markup' => '<h4>{{ label }}</h4>' );
133  echo $gravityview->template->the_field( $field, $entry, $extras );
134  }
135  ?></div><?php
136  }
137 
138  if ( $has_content_attributes ) {
139  ?><div class="gv-grid-col-3-3 gv-list-view-content-attributes"><?php
140  foreach ( $attributes->all() as $i => $field ) {
141  $extras = array( 'zone_id' => 'directory_list-content-attributes', 'markup' => '<p id="{{ field_id }}" class="{{ class }}">{{ label }}{{ value }}</p>' );
142  echo $gravityview->template->the_field( $field, $entry, $extras );
143  }
144  ?></div><?php
145  }
146 
147  /** @action `gravityview/template/list/entry/content/after` */
148  $template::entry_after( $entry, $gravityview, 'content' );
149  ?>
150 
151  </div>
152 
153  <?php
154  }
155 
156  /**
157  * @var bool $has_footer_left
158  * @var bool $has_footer_right
159  * @var \GV\Field_Collection $footer_left
160  * @var \GV\Field_Collection $footer_right
161  */
162  extract( $template->extract_zone_vars( array( 'footer-left', 'footer-right' ) ) );
163 
164  // Is the footer configured?
165  if ( $has_footer_left || $has_footer_right ) {
166  /** @action `gravityview/template/list/entry/footer/before` */
167  $template::entry_before( $entry, $gravityview, 'footer' );
168  ?>
169 
170  <div class="gv-grid gv-list-view-footer">
171  <div class="gv-grid-col-1-2 gv-left">
172  <?php
173  foreach ( $footer_left->all() as $i => $field ) {
174  echo $gravityview->template->the_field( $field, $entry, array( 'zone_id' => 'directory_list-footer-left' ) );
175  }
176  ?>
177  </div>
178 
179  <div class="gv-grid-col-1-2 gv-right">
180  <?php
181  foreach ( $footer_right->all() as $i => $field ) {
182  echo $gravityview->template->the_field( $field, $entry, array( 'zone_id' => 'directory_list-footer-right' ) );
183  }
184  ?>
185  </div>
186  </div>
187 
188  <?php
189 
190  /** @action `gravityview/template/list/entry/footer/after` */
191  $template::entry_after( $entry, $gravityview, 'footer' );
192 
193  } // End if footer is configured
194 
195  /** @action `gravityview/template/list/entry/after` */
196  $template::entry_after( $entry, $gravityview );
197 
198  ?>
199 
200  </div>
201 
202  <?php }
203 }
204 
205 /** @action `gravityview/template/list/body/after` */
206 $template::body_after( $gravityview );
$image
Definition: post_image.php:98
gv_no_results( $wpautop=true, $context=null)
Definition: class-api.php:930
if(! isset( $gravityview)||empty( $gravityview->template)) $template
The entry loop for the list output.
gravityview()
Definition: _stubs.php:26
static get_entry_slug( $id_or_string, $entry=array())
Get the entry slug for the entry.
Definition: class-api.php:538
$entry_slug
Definition: notes.php:30
$entry
Definition: notes.php:27
$field
Definition: gquiz_grade.php:11
$description
Definition: post_image.php:28
$title