GravityView  2.17
The best, easiest way to display Gravity Forms entries on your website.
field-fileupload-html.php
Go to the documentation of this file.
1 <?php
2 /**
3  * The default file upload field output template.
4  *
5  * @global \GV\Template_Context $gravityview
6  * @since 2.0
7  */
8 
9 if ( ! isset( $gravityview ) || empty( $gravityview->template ) ) {
10  gravityview()->log->error( '{file} template loaded without context', array( 'file' => __FILE__ ) );
11  return;
12 }
13 
14 $field = $gravityview->field->field;
15 $value = $gravityview->value;
16 $form = $gravityview->view->form->form;
17 $entry = $gravityview->entry->as_entry();
18 
19 $output = '';
20 
21 if ( ! empty( $value ) ) {
22 
23  $gv_class = gv_class( $field, $form, $entry );
24 
25  $output_arr = gravityview_get_files_array( $value, $gv_class, $gravityview );
26 
27  // If the output array is just one item, let's not show a list.
28  if ( sizeof( $output_arr ) === 1 ) {
29  $output = $output_arr[0]['content'];
30  }
31 
32  // There are multiple files
33  else {
34 
35  // For each file, show as a list
36  foreach ( $output_arr as $key => $item) {
37 
38  // Fix empty lists
39  if ( empty( $item['content'] ) ) { continue; }
40 
41  $output .= '<li>' . $item['content'] . '</li>';
42  }
43 
44  if ( ! empty( $output ) ) {
45  $output = sprintf( "<ul class='gv-field-file-uploads %s'>%s</ul>", $gv_class, $output );
46  }
47  }
48 
49 }
50 
51 echo $output;
gravityview_get_files_array( $value, $gv_class='', $context=null)
Return an array of files prepared for output.
Definition: class-api.php:1375
if(! isset( $gravityview)||empty( $gravityview->template)) $field
The default file upload field output template.
gv_class( $field, $form=NULL, $entry=array())
Definition: class-api.php:840
gravityview()
The main GravityView wrapper function.