當前位置: 首頁>>代碼示例>>PHP>>正文


PHP GravityView_View::setPostId方法代碼示例

本文整理匯總了PHP中GravityView_View::setPostId方法的典型用法代碼示例。如果您正苦於以下問題:PHP GravityView_View::setPostId方法的具體用法?PHP GravityView_View::setPostId怎麽用?PHP GravityView_View::setPostId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在GravityView_View的用法示例。


在下文中一共展示了GravityView_View::setPostId方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: render_view

 /**
  * Core function to render a View based on a set of arguments
  *
  * @access public
  * @static
  * @param array $passed_args {
  *
  *      Settings for rendering the View
  *
  *      @type int $id View id
  *      @type int $page_size Number of entries to show per page
  *      @type string $sort_field Form field id to sort
  *      @type string $sort_direction Sorting direction ('ASC' or 'DESC')
  *      @type string $start_date - Ymd
  *      @type string $end_date - Ymd
  *      @type string $class - assign a html class to the view
  *      @type string $offset (optional) - This is the start point in the current data set (0 index based).
  * }
  *
  * @return string|null HTML output of a View, NULL if View isn't found
  */
 public function render_view($passed_args)
 {
     // validate attributes
     if (empty($passed_args['id'])) {
         do_action('gravityview_log_error', '[render_view] Returning; no ID defined.', $passed_args);
         return null;
     }
     // Solve problem when loading content via admin-ajax.php
     // @hack
     if (!$this->getGvOutputData()) {
         do_action('gravityview_log_error', '[render_view] gv_output_data not defined; parsing content.', $passed_args);
         $this->parse_content();
     }
     // Make 100% sure that we're dealing with a properly called situation
     if (!is_object($this->getGvOutputData()) || !is_callable(array($this->getGvOutputData(), 'get_view'))) {
         do_action('gravityview_log_error', '[render_view] gv_output_data not an object or get_view not callable.', $this->getGvOutputData());
         return null;
     }
     $view_id = $passed_args['id'];
     $view_data = $this->getGvOutputData()->get_view($view_id, $passed_args);
     do_action('gravityview_log_debug', '[render_view] View Data: ', $view_data);
     do_action('gravityview_log_debug', '[render_view] Init View. Arguments: ', $passed_args);
     // The passed args were always winning, even if they were NULL.
     // This prevents that. Filters NULL, FALSE, and empty strings.
     $passed_args = array_filter($passed_args, 'strlen');
     //Override shortcode args over View template settings
     $atts = wp_parse_args($passed_args, $view_data['atts']);
     do_action('gravityview_log_debug', '[render_view] Arguments after merging with View settings: ', $atts);
     // It's password protected and you need to log in.
     if (post_password_required($view_id)) {
         do_action('gravityview_log_error', sprintf('[render_view] Returning: View %d is password protected.', $view_id));
         // If we're in an embed or on an archive page, show the password form
         if (get_the_ID() !== $view_id) {
             return get_the_password_form();
         }
         // Otherwise, just get outta here
         return null;
     }
     /**
      * Don't render View if user isn't allowed to see it
      * @since 1.15
      */
     if (is_user_logged_in() && false === GVCommon::has_cap('read_gravityview', $view_id)) {
         return null;
     }
     if ($this->isGravityviewPostType()) {
         /**
          * @filter `gravityview_direct_access` Should Views be directly accessible, or only visible using the shortcode?
          * @see https://codex.wordpress.org/Function_Reference/register_post_type#public
          * @see GravityView_Post_Types::init_post_types
          * @since 1.15.2
          * @param[in,out] boolean `true`: allow Views to be accessible directly. `false`: Only allow Views to be embedded via shortcode. Default: `true`
          * @param int $view_id The ID of the View currently being requested. `0` for general setting
          */
         $direct_access = apply_filters('gravityview_direct_access', true, $view_id);
         $embed_only = !empty($atts['embed_only']);
         if (!$direct_access || $embed_only && !GVCommon::has_cap('read_private_gravityviews')) {
             return __('You are not allowed to view this content.', 'gravityview');
         }
     }
     ob_start();
     /**
      * 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);
//.........這裏部分代碼省略.........
開發者ID:kidaak,項目名稱:GravityView,代碼行數:101,代碼來源:class-frontend-views.php


注:本文中的GravityView_View::setPostId方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。