5 if ( ! defined(
'GRAVITYVIEW_DIR' ) ) {
29 public function render(
View $view,
Request $request = null ) {
30 if ( is_null( $request ) ) {
34 if ( ! $request->is_renderable() ) {
35 gravityview()->log->error(
'Renderer unable to render View in {request_class} context', array(
'request_class' => get_class( $request ) ) );
47 $template_slug = apply_filters(
'gravityview_template_slug_' . $view->settings->get(
'template' ),
'table',
'directory' );
57 $get_entries = apply_filters(
'gravityview_get_view_entries_' . $template_slug,
true );
59 $hide_until_searched = $view->settings->get(
'hide_until_searched' );
64 $get_entries = ( $hide_until_searched && ! $request->is_search() ) ?
false : $get_entries;
72 $entries = new \GV\Entry_Collection();
78 $override = new \GV\Legacy_Override_Template( $view, null, null, $request );
79 foreach ( array(
'header',
'body',
'footer' ) as $part ) {
81 $path = $override->get_template_part( $template_slug, $part );
83 if ( $path && strpos( $path,
'/deprecated' ) ===
false ) {
87 gravityview()->log->notice(
'Legacy templates detected in theme {path}', array(
'path' => $path ) );
92 add_action(
'gravityview_before', $this->legacy_template_warning( $view, $path ) );
94 return $override->render( $template_slug );
105 $class = apply_filters(
'gravityview/template/view/class', sprintf(
'\GV\View_%s_Template', ucfirst( $template_slug ) ), $view, $request );
107 gravityview()->log->notice(
'{template_class} not found, falling back to legacy', array(
'template_class' =>
$class ) );
108 $class =
'\GV\View_Legacy_Template';
119 static $counter = array();
121 $counter[ $view->ID ] = isset( $counter[ $view->ID ] ) ? $counter[ $view->ID ] + 1 : 1;
129 add_action(
'gravityview/template/view/render', $add_anchor_id_filter =
function ( $context ) use ( &$counter ) {
131 $context->view->set_anchor_id( $counter[ $context->view->ID ] );
134 $add_search_action_filter =
function ( $action ) use ( $view ) {
144 if ( apply_filters(
'gravityview/widget/search/append_view_id_anchor',
true ) ) {
153 add_filter(
'gravityview/widget/search/form/action', $add_search_action_filter );
160 $parameters = $view->settings->as_atts();
161 if ( ! empty( $parameters[
'sort_field'] ) && is_array( $parameters[
'sort_field'] ) ) {
162 $has_multisort =
true;
163 $parameters[
'sort_field'] = reset( $parameters[
'sort_field'] );
164 if ( ! empty( $parameters[
'sort_direction'] ) && is_array( $parameters[
'sort_direction'] ) ) {
165 $parameters[
'sort_direction'] = reset( $parameters[
'sort_direction'] );
170 $parameters = \GravityView_frontend::get_view_entries_parameters( $parameters, $view->form->ID );
178 'request' => $request,
179 ), empty( $parameters ) ? array() : array(
180 'paging' => $parameters[
'paging'],
181 'sorting' => $parameters[
'sorting'],
182 ), empty( $post ) ? array() : array(
186 add_action(
'gravityview/template/after', $view_id_output =
function( $context ) {
187 printf(
'<input type="hidden" class="gravityview-view-id" value="%d">', $context->view->ID );
193 remove_action(
'gravityview/template/after', $view_id_output );
194 remove_filter(
'gravityview/template/view/render', $add_anchor_id_filter );
195 remove_filter(
'gravityview/widget/search/form/action', $add_search_action_filter );
198 return ob_get_clean();
If this file is called directly, abort.
if(! isset( $gravityview)||empty( $gravityview->template)) $template
The entry loop for the list output.
If this file is called directly, abort.
static pop()
Restores last saved state and context.
static push( $configuration)
Set the state depending on the provided configuration.
If this file is called directly, abort.
If this file is called directly, abort.
gravityview()
The main GravityView wrapper function.
get_entries( $request=null)
Retrieve the entries for the current view and request.
get_anchor_id()
Returns the anchor ID to be used in the View container HTML id attribute.