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