GravityView  2.17
The best, easiest way to display Gravity Forms entries on your website.
Public Member Functions | Static Public Member Functions | Data Fields | Static Public Attributes | Protected Attributes
GravityView_View Class Reference

If this file is called directly, abort. More...

Inheritance diagram for GravityView_View:

Public Member Functions

 __construct ( $atts=array())
 Construct the view object. More...
 
 __get ( $name)
 Magic Method: Instead of throwing an error when a variable isn't set, return null. More...
 
 _include ( $path)
 Include a file inside this context. More...
 
 add_id_specific_templates ( $templates, $slug, $name)
 Enable overrides of GravityView templates on a granular basis. More...
 
 clearCurrentEntry ()
 Clear the current entry after all entries in the loop have been displayed. More...
 
 getAtts ( $key=NULL)
 
 getBackLinkLabel ( $do_replace=true)
 
 getContext ()
 
 getContextFields ( $context='')
 Get the fields for a specific context. More...
 
 getCurrentEntry ()
 Return the current entry. More...
 
 getCurrentField ( $key=NULL)
 
 getCurrentFieldSetting ( $key)
 
 getEntries ()
 
 getField ( $key)
 
 getFields ( $key=null)
 
 getForm ()
 
 getFormId ()
 
 getPaginationCounts ()
 Get an array with pagination information. More...
 
 getPaging ()
 
 getPostId ()
 
 getSorting ()
 
 getTemplatePartName ()
 
 getTemplatePartSlug ()
 
 getTotalEntries ()
 
 getViewId ()
 
 isHideUntilSearched ()
 
 locate_template ( $template_names, $load=false, $require_once=true)
 In order to improve lookup times, we store located templates in a local array. More...
 
 render ( $slug, $name, $require_once=true)
 
 render_widget_hooks ( $view_id_or_context)
 Output the widgets on before/after hooks. More...
 
 renderZone ( $zone='', $atts=array(), $echo=true)
 Render an output zone, as configured in the Admin. More...
 
 setAtts ( $atts)
 
 setBackLinkLabel ( $back_link_label)
 
 setContext ( $context)
 
 setCurrentEntry ( $current_entry)
 
 setCurrentField ( $passed_field)
 
 setCurrentFieldSetting ( $key, $value)
 
 setEntries ( $entries)
 
 setField ( $key, $value)
 
 setFields ( $fields)
 
 setForm ( $form)
 
 setFormId ( $form_id)
 
 setHideUntilSearched ( $hide_until_searched)
 
 setPaging ( $paging)
 
 setPostId ( $post_id)
 
 setSorting ( $sorting)
 
 setTemplatePartName ( $template_part_name)
 
 setTemplatePartSlug ( $template_part_slug)
 
 setTotalEntries ( $total_entries)
 
 setViewId ( $view_id)
 

Static Public Member Functions

static getInstance ( $passed_post=NULL)
 

Data Fields

 $view_id = null
 

Static Public Attributes

static $instance = NULL
 

Protected Attributes

 $_current_entry = array()
 Current entry in the loop. More...
 
 $_current_field = array()
 
 $atts = array()
 
 $back_link_label = ''
 
 $context = 'directory'
 
 $entries = array()
 
 $fields = array()
 
 $filter_prefix = 'gravityview'
 Prefix for filter names. More...
 
 $form = null
 
 $form_id = null
 
 $hide_until_searched = false
 
 $located_templates = array()
 Store templates locations that have already been located. More...
 
 $paging = array()
 
 $plugin_directory = GRAVITYVIEW_DIR
 Reference to the root directory path of this plugin. More...
 
 $post_id = null
 
 $sorting = array()
 
 $template_part_name = ''
 The name of the file part, like "body" or "single". More...
 
 $template_part_slug = ''
 The name of the template, like "list", "table", or "datatables". More...
 
 $theme_template_directory = 'gravityview'
 Directory name where custom templates for this plugin should be found in the theme. More...
 
 $total_entries = 0
 

Detailed Description

If this file is called directly, abort.

Definition at line 23 of file class-template.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $atts = array())

Construct the view object.

Parameters
array$attsAssociative array to set the data of

Clear the current entry after the loop is done

Since
1.7.3

Definition at line 155 of file class-template.php.

References $atts, and $value.

Member Function Documentation

◆ __get()

__get (   $name)

Magic Method: Instead of throwing an error when a variable isn't set, return null.

Parameters
string$nameKey for the data retrieval.
Returns
mixed|null The stored data.

Definition at line 764 of file class-template.php.

References $name.

◆ _include()

_include (   $path)

Include a file inside this context.

Parameters
string$pathA path to the legacy template to include.
Returns
void

Definition at line 967 of file class-template.php.

◆ add_id_specific_templates()

add_id_specific_templates (   $templates,
  $slug,
  $name 
)

Enable overrides of GravityView templates on a granular basis.

The loading order is:

  • view-[View ID]-table-footer.php
  • form-[Form ID]-table-footer.php
  • page-[ID of post or page where view is embedded]-table-footer.php
  • table-footer.php
See also
Gamajo_Template_Loader::get_template_file_names() Where the filter is
Parameters
array$templatesExisting list of templates.
string$slugName of the template base, example: table, list, datatables, map
string$nameName of the template part, example: body, footer, head, single
Returns
array $templates Modified template array, merged with existing $templates values

Definition at line 789 of file class-template.php.

References $name, $templates, $view_id, getFormId(), getPostId(), getViewId(), and gravityview().

◆ clearCurrentEntry()

clearCurrentEntry ( )

Clear the current entry after all entries in the loop have been displayed.

Since
1.7.3
Returns
void

Definition at line 633 of file class-template.php.

◆ getAtts()

getAtts (   $key = NULL)
Parameters
string | null$keyThe key to a specific field in the fields array
Returns
array|mixed|null If $key is set and field exists at $key, return that. If not set, return NULL. Otherwise, return array of fields.

Definition at line 260 of file class-template.php.

References $atts.

Referenced by renderZone().

◆ getBackLinkLabel()

getBackLinkLabel (   $do_replace = true)
Parameters
boolean$do_replacePerform merge tag and shortcode processing on the label. Default: true.
Since
2.0
Returns
string

Definition at line 540 of file class-template.php.

References $back_link_label, getCurrentEntry(), getForm(), and GravityView_API\replace_variables().

◆ getContext()

getContext ( )
Returns
string

Definition at line 310 of file class-template.php.

References $context.

Referenced by getContextFields(), getCurrentEntry(), and renderZone().

◆ getContextFields()

getContextFields (   $context = '')

Get the fields for a specific context.

Since
1.19.2
Parameters
string$context[Optional] "directory", "single", or "edit"
Returns
array Array of GravityView field layout configurations

Definition at line 345 of file class-template.php.

References $context, $fields, getContext(), and getFields().

◆ getCurrentEntry()

getCurrentEntry ( )

Return the current entry.

If in the loop, the current entry. If single entry, the currently viewed entry.

Returns
array
Since
1.16 Fixes DataTables empty entry issue

Definition at line 602 of file class-template.php.

References $_current_entry, $entries, $entry, getContext(), and getEntries().

Referenced by getBackLinkLabel(), and renderZone().

◆ getCurrentField()

getCurrentField (   $key = NULL)
Parameters
string | null$keyThe key to a specific attribute of the current field
Returns
array|mixed|null If $key is set and attribute exists at $key, return that. If not set, return NULL. Otherwise, return current field array

Definition at line 208 of file class-template.php.

References $_current_field.

Referenced by getCurrentFieldSetting(), and setCurrentField().

◆ getCurrentFieldSetting()

getCurrentFieldSetting (   $key)

Definition at line 228 of file class-template.php.

References $settings, and getCurrentField().

◆ getEntries()

getEntries ( )
Returns
array

Definition at line 427 of file class-template.php.

References $entries.

Referenced by getCurrentEntry().

◆ getField()

getField (   $key)
Parameters
string$keyThe key to a specific field in the fields array
Returns
array|mixed|null If $key is set and field exists at $key, return that. If not set, return NULL. Otherwise, return array of fields.

Definition at line 377 of file class-template.php.

Referenced by renderZone().

◆ getFields()

getFields (   $key = null)
Parameters
string | null$keyThe key to a specific field in the fields array
Returns
array|mixed|null If $key is set and field exists at $key, return that. If not set, return NULL. Otherwise, return array of fields.

Definition at line 325 of file class-template.php.

References $fields.

Referenced by getContextFields().

◆ getForm()

getForm ( )
Returns
array

Definition at line 282 of file class-template.php.

References $form.

Referenced by getBackLinkLabel(), and renderZone().

◆ getFormId()

getFormId ( )
Returns
int

Definition at line 413 of file class-template.php.

References $form_id.

Referenced by add_id_specific_templates().

◆ getInstance()

static getInstance (   $passed_post = NULL)
static
Parameters
null$passed_post
Returns
GravityView_View

Definition at line 195 of file class-template.php.

Referenced by GravityView_frontend\add_columns_sort_links(), View_List_Template\body_after(), View_Table_Template\body_after(), View_List_Template\body_before(), View_Table_Template\body_before(), GravityView_Delete_Entry\check_user_cap_delete_entry(), GravityView_Edit_Entry\check_user_cap_edit_entry(), GravityView_frontend\context_not_configured_warning(), GravityView_API\directory_link(), GravityView_Field_Notes\display_note(), GravityView_Plugin_Hooks_Gravity_Forms_Signature\edit_entry_field_input(), GravityView_Widget_Search\enqueue_datepicker(), View_List_Template\entry_after(), View_List_Template\entry_before(), View_List_Template\entry_class(), View_Table_Template\entry_class(), GravityView_API\field_class(), GravityView_API\field_html_attr_id(), GravityView_API\field_label(), Legacy_Context\freeze(), GravityView_Field_Notes\get_add_note_part(), GravityView_Entry_Link_Shortcode\get_entry(), GravityView_Field_FileUpload\get_files_array(), GravityView_Field_Notes\get_note_emails_array(), GravityView_Entry_List\get_output(), GravityView_Widget_Search\get_search_class(), GravityView_frontend\get_search_criteria_paging(), GravityView_Widget_Search\get_search_filter_details(), GravityView_Widget_Search\get_search_form_action(), GravityView_Plugin_Hooks_Gravity_Flow\get_status_options(), GravityView_Shortcode\get_view_detail(), GravityView_Field_Workflow_Step\get_workflow_step(), gravityview_back_link(), gravityview_get_view_id(), gv_container_class(), Legacy_Context\load(), GravityView_Field_Workflow_Step\modify_frontend_search_fields(), GravityView_API\no_results(), GravityView_Edit_Entry_Render\print_scripts(), GravityView_Field_Entry_Approval\register_scripts_and_styles(), Entry_Legacy_Template\render(), View_Legacy_Template\render(), Legacy_Override_Template\render(), GravityView_Widget_Page_Links\render_frontend(), GravityView_Widget_Pagination_Info\render_frontend(), GravityView_Widget_Poll\render_frontend(), oEmbed\render_frontend(), GravityView_Widget_Search\render_frontend(), render_widget_hooks(), GravityView_Field_Sequence\replace_merge_tag(), GravityView_Field_Address\search_field_filter(), GravityView_Edit_Entry_Render\setup_vars(), GravityView_Entry_Link_Shortcode\shortcode(), Legacy_Context\thaw(), GravityView_Widget_Search\the_clear_search_button(), Entry_Table_Template\the_entry(), View_Table_Template\the_entry(), View_Table_Template\tr_after(), View_Table_Template\tr_before(), and GravityView_Search_WP_Widget\widget().

◆ getPaginationCounts()

getPaginationCounts ( )

Get an array with pagination information.

Since
1.13
Returns
array { int $first The starting entry number (counter, not ID) int $last The last displayed entry number (counter, not ID) int $total The total number of entries }
Runs Filter:
gravityview_pagination_counts Modify the displayed pagination numbers
Since
1.13
Parameters
array$countsArray with $first, $last, $total numbers in that order

Definition at line 483 of file class-template.php.

References $paging, getPaging(), getTotalEntries(), and gravityview().

◆ getPaging()

getPaging ( )
Returns
array

Definition at line 455 of file class-template.php.

Referenced by getPaginationCounts().

◆ getPostId()

getPostId ( )
Returns
int|null

Definition at line 296 of file class-template.php.

References $post_id.

Referenced by add_id_specific_templates().

◆ getSorting()

getSorting ( )
Returns
array

Definition at line 514 of file class-template.php.

◆ getTemplatePartName()

getTemplatePartName ( )
Returns
string

Definition at line 587 of file class-template.php.

References $template_part_name.

◆ getTemplatePartSlug()

getTemplatePartSlug ( )
Returns
string

Definition at line 573 of file class-template.php.

References $template_part_slug.

Referenced by renderZone().

◆ getTotalEntries()

getTotalEntries ( )
Returns
int

Definition at line 441 of file class-template.php.

References $total_entries.

Referenced by getPaginationCounts().

◆ getViewId()

getViewId ( )
Returns
int

Definition at line 399 of file class-template.php.

Referenced by add_id_specific_templates().

◆ isHideUntilSearched()

isHideUntilSearched ( )
Returns
boolean

Definition at line 559 of file class-template.php.

References $hide_until_searched.

◆ locate_template()

locate_template (   $template_names,
  $load = false,
  $require_once = true 
)

In order to improve lookup times, we store located templates in a local array.

This improves performance by up to 1/2 second on a 250 entry View with 7 columns showing

See also
Gamajo_Template_Loader::locate_template()
Returns
null|string NULL: Template not found; String: path to template

Definition at line 736 of file class-template.php.

◆ render()

render (   $slug,
  $name,
  $require_once = true 
)

Definition at line 816 of file class-template.php.

References $name, gravityview(), setTemplatePartName(), and setTemplatePartSlug().

◆ render_widget_hooks()

render_widget_hooks (   $view_id_or_context)

Output the widgets on before/after hooks.

Parameters
int | \GV\Template_Context$view_id_or_contextThe View ID or the context.
Returns
void

Fake new context for legacy template code.

Prevent output if no widgets to show.

Since
1.16
Runs Filter:
gravityview/widgets/wrapper_css_class The CSS class applied to the widget container <div>.
Since
1.16.2
Parameters
string$css_classDefault: gv-grid gv-widgets-{zone} where {zone} is replaced by the current $zone value. If the View has no results, adds gv-widgets-no-results
string$zoneCurrent widget zone, either header or footer
array$widgetsArray of widget configurations for the current zone, as set by `gravityview_get_current_view_data()['widgets']`

Prevent widgets from being called twice. Checking for loop_start prevents themes and plugins that pre-process shortcodes from triggering the action before displaying. Like, ahem, the Divi theme and WordPress SEO plugin

Definition at line 844 of file class-template.php.

References $total_entries, View\by_id(), Template_Context\from_template(), Widget\get_default_widget_areas(), getInstance(), gravityview(), and gravityview_get_context().

◆ renderZone()

renderZone (   $zone = '',
  $atts = array(),
  $echo = true 
)

Render an output zone, as configured in the Admin.

Since
1.16.4 Added $echo parameter
Parameters
string$zoneThe zone name, like 'footer-left'
array$atts
bool$echoWhether to print the output
Returns
string|null
Runs Filter:
gravityview_table_cells Modify the fields displayed in a table
Parameters
array$fields
\GravityView_View$this

If a zone has no field output, choose whether to show wrapper False by default to keep backward compatibility

Since
1.7.6
Parameters
boolean$hide_empty_zoneDefault: false
Since
2.0
Parameters
\GV\Template_Context$contextThe context. Null here. Since this path is deprecated.

Definition at line 650 of file class-template.php.

References $atts, $field, $fields, $output, getAtts(), getContext(), getCurrentEntry(), getField(), getForm(), getTemplatePartSlug(), gravityview(), and gravityview_field_output().

◆ setAtts()

setAtts (   $atts)
Parameters
array$atts

Definition at line 275 of file class-template.php.

References $atts.

◆ setBackLinkLabel()

setBackLinkLabel (   $back_link_label)
Parameters
string$back_link_label

Definition at line 552 of file class-template.php.

References $back_link_label.

◆ setContext()

setContext (   $context)
Parameters
string$context

Definition at line 317 of file class-template.php.

References $context.

◆ setCurrentEntry()

setCurrentEntry (   $current_entry)
Parameters
array$current_entry
Returns
void

Definition at line 623 of file class-template.php.

◆ setCurrentField()

setCurrentField (   $passed_field)
Parameters
array$passed_field

Backward compatibility

Definition at line 241 of file class-template.php.

References getCurrentField().

◆ setCurrentFieldSetting()

setCurrentFieldSetting (   $key,
  $value 
)

Definition at line 220 of file class-template.php.

References $value.

◆ setEntries()

setEntries (   $entries)
Parameters
array$entries

Definition at line 434 of file class-template.php.

References $entries.

◆ setField()

setField (   $key,
  $value 
)
Parameters
string$keyThe key to a specific field in the fields array
mixed$valueThe value to set for the field

Definition at line 392 of file class-template.php.

References $value.

◆ setFields()

setFields (   $fields)
Parameters
array$fields

Definition at line 369 of file class-template.php.

References $fields.

◆ setForm()

setForm (   $form)
Parameters
array$form

Definition at line 289 of file class-template.php.

References $form.

◆ setFormId()

setFormId (   $form_id)
Parameters
int$form_id

Definition at line 420 of file class-template.php.

References $form_id.

◆ setHideUntilSearched()

setHideUntilSearched (   $hide_until_searched)
Parameters
boolean$hide_until_searched

Definition at line 566 of file class-template.php.

References $hide_until_searched.

◆ setPaging()

setPaging (   $paging)
Parameters
array$paging

Definition at line 468 of file class-template.php.

References $paging.

◆ setPostId()

setPostId (   $post_id)
Parameters
int | null$post_id

Definition at line 303 of file class-template.php.

References $post_id.

◆ setSorting()

setSorting (   $sorting)
Parameters
array$sorting

Definition at line 528 of file class-template.php.

References $sorting.

◆ setTemplatePartName()

setTemplatePartName (   $template_part_name)
Parameters
string$template_part_name

Definition at line 594 of file class-template.php.

References $template_part_name.

Referenced by render().

◆ setTemplatePartSlug()

setTemplatePartSlug (   $template_part_slug)
Parameters
string$template_part_slug

Definition at line 580 of file class-template.php.

References $template_part_slug.

Referenced by render().

◆ setTotalEntries()

setTotalEntries (   $total_entries)
Parameters
int$total_entries

Definition at line 448 of file class-template.php.

References $total_entries.

◆ setViewId()

setViewId (   $view_id)
Parameters
int$view_id

Definition at line 406 of file class-template.php.

References $view_id.

Field Documentation

◆ $_current_entry

array $_current_entry = array()
protected

Current entry in the loop.

Definition at line 139 of file class-template.php.

Referenced by getCurrentEntry().

◆ $_current_field

array $_current_field = array()
protected

Definition at line 144 of file class-template.php.

Referenced by getCurrentField().

◆ $atts

$atts = array()
protected

Definition at line 101 of file class-template.php.

Referenced by __construct(), getAtts(), renderZone(), and setAtts().

◆ $back_link_label

$back_link_label = ''
protected

Definition at line 116 of file class-template.php.

Referenced by getBackLinkLabel(), and setBackLinkLabel().

◆ $context

$context = 'directory'
protected

Definition at line 86 of file class-template.php.

Referenced by getContext(), getContextFields(), and setContext().

◆ $entries

$entries = array()
protected

Definition at line 106 of file class-template.php.

Referenced by getCurrentEntry(), getEntries(), and setEntries().

◆ $fields

$fields = array()
protected

Definition at line 81 of file class-template.php.

Referenced by getContextFields(), getFields(), renderZone(), and setFields().

◆ $filter_prefix

string $filter_prefix = 'gravityview'
protected

Prefix for filter names.

Definition at line 30 of file class-template.php.

◆ $form

$form = null
protected

Definition at line 96 of file class-template.php.

Referenced by getForm(), and setForm().

◆ $form_id

array $form Gravity Forms form array at ID $form_id = null
protected

Definition at line 70 of file class-template.php.

Referenced by getFormId(), and setFormId().

◆ $hide_until_searched

$hide_until_searched = false
protected

Definition at line 132 of file class-template.php.

Referenced by isHideUntilSearched(), and setHideUntilSearched().

◆ $instance

GravityView_View $instance = NULL
static

Definition at line 149 of file class-template.php.

Referenced by oEmbed\render_frontend(), and Legacy_Context\reset().

◆ $located_templates

array $located_templates = array()
protected

Store templates locations that have already been located.

Definition at line 51 of file class-template.php.

◆ $paging

$paging = array()
protected

Definition at line 121 of file class-template.php.

Referenced by getPaginationCounts(), and setPaging().

◆ $plugin_directory

string $plugin_directory = GRAVITYVIEW_DIR
protected

Reference to the root directory path of this plugin.

Definition at line 44 of file class-template.php.

◆ $post_id

$post_id = null
protected

Definition at line 91 of file class-template.php.

Referenced by getPostId(), and setPostId().

◆ $sorting

$sorting = array()
protected

Definition at line 126 of file class-template.php.

Referenced by setSorting().

◆ $template_part_name

string $template_part_name = ''
protected

The name of the file part, like "body" or "single".

Definition at line 65 of file class-template.php.

Referenced by getTemplatePartName(), and setTemplatePartName().

◆ $template_part_slug

string $template_part_slug = ''
protected

The name of the template, like "list", "table", or "datatables".

Definition at line 58 of file class-template.php.

Referenced by getTemplatePartSlug(), and setTemplatePartSlug().

◆ $theme_template_directory

string $theme_template_directory = 'gravityview'
protected

Directory name where custom templates for this plugin should be found in the theme.

Definition at line 37 of file class-template.php.

◆ $total_entries

$total_entries = 0
protected

Definition at line 111 of file class-template.php.

Referenced by getTotalEntries(), render_widget_hooks(), and setTotalEntries().

◆ $view_id

$view_id = null

Definition at line 76 of file class-template.php.

Referenced by add_id_specific_templates(), and setViewId().


The documentation for this class was generated from the following file: