当前位置: 首页>>代码示例>>PHP>>正文


PHP GravityView_View::setTotalEntries方法代码示例

本文整理汇总了PHP中GravityView_View::setTotalEntries方法的典型用法代码示例。如果您正苦于以下问题:PHP GravityView_View::setTotalEntries方法的具体用法?PHP GravityView_View::setTotalEntries怎么用?PHP GravityView_View::setTotalEntries使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GravityView_View的用法示例。


在下文中一共展示了GravityView_View::setTotalEntries方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: render_view


//.........这里部分代码省略.........
     /**
      * Set globals for templating
      * @deprecated 1.6.2
      */
     global $gravityview_view;
     $gravityview_view = new GravityView_View($view_data);
     $post_id = !empty($atts['post_id']) ? intval($atts['post_id']) : $this->getPostId();
     $gravityview_view->setPostId($post_id);
     if (!$this->getSingleEntry()) {
         // user requested Directory View
         do_action('gravityview_log_debug', '[render_view] Executing Directory View');
         //fetch template and slug
         $view_slug = apply_filters('gravityview_template_slug_' . $view_data['template_id'], 'table', 'directory');
         do_action('gravityview_log_debug', '[render_view] View template slug: ', $view_slug);
         /**
          * Disable fetching initial entries for views that don't need it (DataTables)
          */
         $get_entries = apply_filters('gravityview_get_view_entries_' . $view_slug, true);
         /**
          * Hide View data until search is performed
          * @since 1.5.4
          */
         if (!empty($atts['hide_until_searched']) && !$this->isSearch()) {
             $gravityview_view->setHideUntilSearched(true);
             $get_entries = false;
         }
         if ($get_entries) {
             if (!empty($atts['sort_columns'])) {
                 // add filter to enable column sorting
                 add_filter('gravityview/template/field_label', array($this, 'add_columns_sort_links'), 100, 3);
             }
             $view_entries = self::get_view_entries($atts, $view_data['form_id']);
             do_action('gravityview_log_debug', sprintf('[render_view] Get Entries. Found %s entries total, showing %d entries', $view_entries['count'], sizeof($view_entries['entries'])));
         } else {
             $view_entries = array('count' => null, 'entries' => null, 'paging' => null);
             do_action('gravityview_log_debug', '[render_view] Not fetching entries because `gravityview_get_view_entries_' . $view_slug . '` is false');
         }
         $gravityview_view->setPaging($view_entries['paging']);
         $gravityview_view->setContext('directory');
         $sections = array('header', 'body', 'footer');
     } else {
         // user requested Single Entry View
         do_action('gravityview_log_debug', '[render_view] Executing Single View');
         do_action('gravityview_render_entry_' . $view_data['id']);
         $entry = $this->getEntry();
         // You are not permitted to view this entry.
         if (empty($entry) || !self::is_entry_approved($entry, $atts)) {
             do_action('gravityview_log_debug', '[render_view] Entry does not exist. This may be because of View filters limiting access.');
             /**
              * @since 1.6
              */
             echo esc_attr(apply_filters('gravityview/render/entry/not_visible', __('You have attempted to view an entry that is not visible or may not exist.', 'gravityview')));
             return null;
         }
         // We're in single view, but the view being processed is not the same view the single entry belongs to.
         // important: do not remove this as it prevents fake attempts of displaying entries from other views/forms
         if ($this->getGvOutputData()->has_multiple_views() && $view_id != $this->get_context_view_id()) {
             do_action('gravityview_log_debug', '[render_view] In single entry view, but the entry does not belong to this View. Perhaps there are multiple views on the page. View ID: ' . $view_id);
             return null;
         }
         //fetch template and slug
         $view_slug = apply_filters('gravityview_template_slug_' . $view_data['template_id'], 'table', 'single');
         do_action('gravityview_log_debug', '[render_view] View single template slug: ', $view_slug);
         //fetch entry detail
         $view_entries['count'] = 1;
         $view_entries['entries'][] = $entry;
         do_action('gravityview_log_debug', '[render_view] Get single entry: ', $view_entries['entries']);
         $back_link_label = isset($atts['back_link_label']) ? $atts['back_link_label'] : null;
         // set back link label
         $gravityview_view->setBackLinkLabel($back_link_label);
         $gravityview_view->setContext('single');
         $sections = array('single');
     }
     // add template style
     self::add_style($view_data['template_id']);
     // Prepare to render view and set vars
     $gravityview_view->setEntries($view_entries['entries']);
     $gravityview_view->setTotalEntries($view_entries['count']);
     // If Edit
     if ('edit' === gravityview_get_context()) {
         do_action('gravityview_log_debug', '[render_view] Edit Entry ');
         do_action('gravityview_edit_entry', $this->getGvOutputData());
         return ob_get_clean();
     } else {
         // finaly we'll render some html
         $sections = apply_filters('gravityview_render_view_sections', $sections, $view_data['template_id']);
         do_action('gravityview_log_debug', '[render_view] Sections to render: ', $sections);
         foreach ($sections as $section) {
             do_action('gravityview_log_debug', '[render_view] Rendering ' . $section . ' section.');
             $gravityview_view->render($view_slug, $section, false);
         }
     }
     //@todo: check why we need the IF statement vs. print the view id always.
     if ($this->isGravityviewPostType() || $this->isPostHasShortcode()) {
         // Print the View ID to enable proper cookie pagination
         echo '<input type="hidden" class="gravityview-view-id" value="' . esc_attr($view_id) . '">';
     }
     $output = ob_get_clean();
     return $output;
 }
开发者ID:kidaak,项目名称:GravityView,代码行数:101,代码来源:class-frontend-views.php


注:本文中的GravityView_View::setTotalEntries方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。