GravityView  2.1.1
The best, easiest way to display Gravity Forms entries on your website.
field-other_entries-html.php
Go to the documentation of this file.
1 <?php
2 /**
3  * The default field output template displaying
4  * entries created by same author.
5  *
6  * @global \GV\Template_Context $gravityview
7  * @since 2.0
8  */
9 
10 $created_by = \GV\Utils::get( $gravityview->entry, 'created_by' );
11 
12 /** There was no logged in user who created this entry. */
13 if ( empty( $created_by ) ) {
14  return;
15 }
16 
17 /** Filter entries by approved and created_by. */
18 $search_criteria = GravityView_frontend::process_search_only_approved( $gravityview->view->settings->as_atts(),
19  array(
20  'field_filters' => array(
21  array(
22  'key' => 'created_by',
23  'value' => $created_by,
24  'operator' => 'is'
25  )
26  ),
27  'status' => apply_filters( 'gravityview_status', 'active', $gravityview->view->settings->as_atts() ),
28  )
29 );
30 
31 /**
32  * @filter `gravityview/field/other_entries/criteria` Modify the search parameters before the entries are fetched.
33  *
34  * @since 1.11
35  *
36  * @param array $criteria Gravity Forms search criteria array, as used by GVCommon::get_entries()
37  * @param array $view_settings Associative array of settings with plugin defaults used if not set by the View
38  * @param int $form_id The Gravity Forms ID
39  * @since 2.0
40  * @param \GV\Template_Context $gravityview The context
41  */
42 $criteria = apply_filters( 'gravityview/field/other_entries/criteria', $search_criteria, $gravityview->view->settings->as_atts(), $gravityview->view->form->ID, $gravityview );
43 
44 /** Force mode all and filter out our own entry. */
45 $search_criteria['field_filters']['mode'] = 'all';
46 $search_criteria['field_filters'][] = array(
47  'key' => 'id',
48  'value' => $gravityview->entry->ID,
49  'operator' => 'isnot'
50 );
52 
53 $entries = $gravityview->view->form->entries->filter( $filter )->limit( $gravityview->field->page_size ? : 10 )->all();
54 
55 /** Don't show if no entries and the setting says so. */
56 if ( empty( $entries ) && $gravityview->field->no_entries_hide ) {
57  return;
58 }
59 
60 /** If there are search results, get the entry list object. */
62  array_map( function( $entry ) { return $entry->as_entry(); }, $entries ),
63  $gravityview->request->is_view() ? $gravityview->view->ID : is_object( $GLOBALS['post'] ) ? $GLOBALS['post']->ID : 0,
64  $gravityview->view->form->form,
65  $gravityview->field->link_format,
66  $gravityview->field->after_link,
67  'other_entries', // Context
68  $gravityview
69 );
70 
71 /** Generate and echo the output. */
72 $list->output();
73 
74 /**
75  * @since 1.7.6
76  * @deprecated since 1.11
77  */
78 $deprecated = apply_filters( 'gravityview/field/other_entries/args', array(), null );
79 if ( ! empty( $deprecated ) ) {
80  _deprecated_function( 'The "gravityview/field/other_entries/args" filter', 'GravityView 1.11', 'gravityview/field/other_entries/criteria' );
81 }
if(empty( $entries) && $gravityview->field->no_entries_hide) $list
Don&#39;t show if no entries and the setting says so.
static from_search_criteria( $search_criteria)
Create a filter from this criteria.
If this file is called directly, abort.
static process_search_only_approved( $args, $search_criteria)
Process the approved only search criteria according to the View settings.
if(empty( $created_by)) $search_criteria
There was no logged in user who created this entry.
$created_by
The default field output template displaying entries created by same author.
static get( $array, $key, $default=null)
Grab a value from an array or an object or default.
$entry
Definition: notes.php:27