GravityView  1.19.4
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...
 
 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 ()
 
 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)
 
 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_field = array()
 
 $atts = array()
 
 $back_link_label = ''
 
 $context = 'directory'
 
 $entries = array()
 
 $fields = array()
 
 $filter_prefix = 'gravityview'
 
 $form = NULL
 
 $form_id = NULL
 
 $hide_until_searched = false
 
 $located_templates = array()
 
 $paging = array()
 
 $plugin_directory = GRAVITYVIEW_DIR
 
 $post_id = NULL
 
 $sorting = array()
 
 $template_part_name = ''
 
 $template_part_slug = ''
 
 $theme_template_directory = 'gravityview'
 
 $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 (   $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 148 of file class-template.php.

References $atts, and $value.

Member Function Documentation

__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 749 of file class-template.php.

References $name.

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 774 of file class-template.php.

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

clearCurrentEntry ( )

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

Since
1.7.3
Returns
void

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

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 255 of file class-template.php.

References $atts.

Referenced by renderZone().

getBackLinkLabel ( )
Returns
string

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

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

getContext ( )
Returns
string

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

References $context.

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

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 340 of file class-template.php.

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

Referenced by GravityView_Welcome\getting_started_screen().

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 592 of file class-template.php.

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

Referenced by getBackLinkLabel(), and renderZone().

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 203 of file class-template.php.

References $_current_field.

Referenced by getCurrentFieldSetting(), and setCurrentField().

getCurrentFieldSetting (   $key)

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

References getCurrentField().

getEntries ( )
Returns
array

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

References $entries.

Referenced by getCurrentEntry().

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 372 of file class-template.php.

Referenced by renderZone().

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 320 of file class-template.php.

References $fields.

Referenced by getContextFields().

getForm ( )
Returns
array

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

References $form.

Referenced by getBackLinkLabel(), and renderZone().

getFormId ( )
Returns
int

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

References $form_id.

Referenced by add_id_specific_templates().

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

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

Referenced by GravityView_frontend\add_columns_sort_links(), GravityView_Field_Address\add_hooks(), 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(), GravityView_API\field_class(), GravityView_API\field_html_attr_id(), GravityView_API\field_label(), GravityView_Field_FileUpload\field_options(), GravityView_API\field_value(), GravityView_Field_Notes\get_add_note_part(), GravityView_Entry_Link_Shortcode\get_entry(), GravityView_Field_Notes\get_note_emails_array(), GravityView_Entry_List\get_output(), GravityView_Widget_Search\get_search_class(), 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_context(), gravityview_get_view_id(), gv_container_class(), GravityView_Widget_Search\has_date_field(), GravityView_Field_Workflow_Step\modify_frontend_search_fields(), GravityView_API\no_results(), GravityView_Widget_Poll\pre_render_frontend(), GravityView_Widget\pre_render_frontend(), GravityView_Widget_Search\prepare_field_filter(), GravityView_Edit_Entry_Render\print_scripts(), GravityView_Field_Entry_Approval\register_scripts_and_styles(), GravityView_Widget_Page_Links\render_frontend(), GravityView_Widget_Pagination_Info\render_frontend(), GravityView_Widget_Poll\render_frontend(), render_widget_hooks(), GravityView_Delete_Entry\set_entry(), GravityView_Edit_Entry_Render\setup_vars(), GravityView_Entry_Link_Shortcode\shortcode(), GravityView_Field_Custom\show_field_in_edit_entry(), GravityView_Widget_Search\the_clear_search_button(), GravityView_frontend\updateViewSorting(), and GravityView_Search_WP_Widget\widget().

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 478 of file class-template.php.

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

getPaging ( )
Returns
array

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

Referenced by getPaginationCounts().

getPostId ( )
Returns
int|null

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

References $post_id.

Referenced by add_id_specific_templates().

getSorting ( )
Returns
array

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

getTemplatePartName ( )
Returns
string

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

References $template_part_name.

getTemplatePartSlug ( )
Returns
string

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

References $template_part_slug.

Referenced by renderZone().

getTotalEntries ( )
Returns
int

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

References $total_entries.

Referenced by getPaginationCounts(), and render_widget_hooks().

getViewId ( )
Returns
int

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

Referenced by add_id_specific_templates().

isHideUntilSearched ( )
Returns
boolean

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

References $hide_until_searched.

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 721 of file class-template.php.

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

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

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

render_widget_hooks (   $view_id)
Parameters
$view_id

Filter widgets not in the current zone

Since
1.16

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 824 of file class-template.php.

References $view_id, GravityView_Plugin\get_default_widget_areas(), getInstance(), getTotalEntries(), gravityview_get_context(), and gravityview_get_current_view_data().

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

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

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

setAtts (   $atts)
Parameters
array$atts

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

References $atts.

setBackLinkLabel (   $back_link_label)
Parameters
string$back_link_label

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

References $back_link_label.

setContext (   $context)
Parameters
string$context

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

References $context.

setCurrentEntry (   $current_entry)
Parameters
array$current_entry
Returns
void

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

setCurrentField (   $passed_field)
Parameters
array$passed_field

Backward compatibility

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

References getCurrentField().

setCurrentFieldSetting (   $key,
  $value 
)

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

References $value.

setEntries (   $entries)
Parameters
array$entries

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

References $entries.

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 387 of file class-template.php.

References $value.

setFields (   $fields)
Parameters
array$fields

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

References $fields.

setForm (   $form)
Parameters
array$form

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

References $form.

setFormId (   $form_id)
Parameters
int$form_id

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

References $form_id.

setHideUntilSearched (   $hide_until_searched)
Parameters
boolean$hide_until_searched

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

References $hide_until_searched.

setPaging (   $paging)
Parameters
array$paging

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

References $paging.

setPostId (   $post_id)
Parameters
int | null$post_id

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

References $post_id.

setSorting (   $sorting)
Parameters
array$sorting

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

References $sorting.

setTemplatePartName (   $template_part_name)
Parameters
string$template_part_name

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

References $template_part_name.

Referenced by render().

setTemplatePartSlug (   $template_part_slug)
Parameters
string$template_part_slug

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

References $template_part_slug.

Referenced by render().

setTotalEntries (   $total_entries)
Parameters
int$total_entries

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

References $total_entries.

setViewId (   $view_id)
Parameters
int$view_id

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

References $view_id.

Field Documentation

$_current_entry = array()
protected

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

Referenced by getCurrentEntry().

$_current_field = array()
protected

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

Referenced by getCurrentField().

$atts = array()
protected

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

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

$back_link_label = ''
protected

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

Referenced by getBackLinkLabel(), and setBackLinkLabel().

$context = 'directory'
protected

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

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

$entries = array()
protected

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

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

$fields = array()
protected

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

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

$filter_prefix = 'gravityview'
protected

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

$form = NULL
protected

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

Referenced by getForm(), and setForm().

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

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

Referenced by getFormId(), and setFormId().

$hide_until_searched = false
protected

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

Referenced by isHideUntilSearched(), and setHideUntilSearched().

$instance = NULL
static

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

$located_templates = array()
protected

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

$paging = array()
protected

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

Referenced by getPaginationCounts(), and setPaging().

$plugin_directory = GRAVITYVIEW_DIR
protected

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

$post_id = NULL
protected

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

Referenced by getPostId(), and setPostId().

$sorting = array()
protected

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

Referenced by setSorting().

$template_part_name = ''
protected

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

Referenced by getTemplatePartName(), and setTemplatePartName().

$template_part_slug = ''
protected

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

Referenced by getTemplatePartSlug(), and setTemplatePartSlug().

$theme_template_directory = 'gravityview'
protected

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

$total_entries = 0
protected

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

Referenced by getTotalEntries(), and setTotalEntries().

$view_id = NULL

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

Referenced by render_widget_hooks(), and setViewId().


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