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


PHP Essential_Grid_Base::get_popular_posts方法代码示例

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


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

示例1: output_by_posts

 /**
  * Output by posts
  */
 public function output_by_posts($grid_preview = false)
 {
     global $sitepress;
     $post_limit = 99999;
     $base = new Essential_Grid_Base();
     $navigation_c = new Essential_Grid_Navigation($this->grid_id);
     $meta_c = new Essential_Grid_Meta();
     $item_skin = new Essential_Grid_Item_Skin();
     $item_skin->grid_id = $this->grid_id;
     $item_skin->set_grid_type($base->getVar($this->grid_params, 'layout', 'even'));
     $item_skin->set_default_image_by_id($base->getVar($this->grid_postparams, 'default-image', 0, 'i'));
     $m = new Essential_Grid_Meta();
     $skins_html = '';
     $skins_css = '';
     $filters = array();
     $rows_unlimited = $base->getVar($this->grid_params, 'rows-unlimited', 'on');
     $load_more = $base->getVar($this->grid_params, 'load-more', 'none');
     $load_more_start = $base->getVar($this->grid_params, 'load-more-start', 3, 'i');
     if ($rows_unlimited == 'on' && $load_more !== 'none' && $grid_preview == false) {
         //grid_preview means disable load more in preview
         $post_limit = $load_more_start;
     }
     $start_sortby = $base->getVar($this->grid_params, 'sorting-order-by-start', 'none');
     $start_sortby_type = $base->getVar($this->grid_params, 'sorting-order-type', 'ASC');
     $post_category = $base->getVar($this->grid_postparams, 'post_category');
     $post_types = $base->getVar($this->grid_postparams, 'post_types');
     $page_ids = explode(',', $base->getVar($this->grid_postparams, 'selected_pages', '-1'));
     $cat_relation = $base->getVar($this->grid_postparams, 'category-relation', 'OR');
     $max_entries = $this->get_maximum_entries($this);
     $additional_query = $base->getVar($this->grid_postparams, 'additional-query', '');
     if ($additional_query !== '') {
         $additional_query = wp_parse_args($additional_query);
     }
     $cat_tax = array('cats' => '', 'tax' => '');
     if ($this->custom_posts !== null) {
         //output by specific set posts
         $posts = Essential_Grid_Base::get_posts_by_ids($this->custom_posts, $start_sortby, $start_sortby_type);
         $cat_tax_obj = Essential_Grid_Base::get_categories_by_posts($posts);
         if (!empty($cat_tax_obj)) {
             $cat_tax['cats'] = Essential_Grid_Base::translate_categories_to_string($cat_tax_obj);
         }
         //$cat_tax = Essential_Grid_Base::getCatAndTaxData($post_category); //get cats by posts
     } elseif ($this->custom_special !== null) {
         //output by some special rule
         $max_entries = intval($base->getVar($this->grid_params, 'max-entries', '20'));
         if ($max_entries == 0) {
             $max_entries = 20;
         }
         switch ($this->custom_special) {
             case 'related':
                 $posts = Essential_Grid_Base::get_related_posts($max_entries);
                 break;
             case 'popular':
                 $posts = Essential_Grid_Base::get_popular_posts($max_entries);
                 break;
             case 'latest':
             default:
                 $posts = Essential_Grid_Base::get_latest_posts($max_entries);
                 break;
         }
         $cat_tax_obj = Essential_Grid_Base::get_categories_by_posts($posts);
         if (!empty($cat_tax_obj)) {
             $cat_tax['cats'] = Essential_Grid_Base::translate_categories_to_string($cat_tax_obj);
         }
         //$cat_tax = Essential_Grid_Base::getCatAndTaxData($post_category);  //get cats by posts
     } else {
         //output with the grid settings from an existing grid
         $cat_tax = Essential_Grid_Base::getCatAndTaxData($post_category);
         $posts = Essential_Grid_Base::getPostsByCategory($this->grid_id, $cat_tax['cats'], $post_types, $cat_tax['tax'], $page_ids, $start_sortby, $start_sortby_type, $max_entries, $additional_query, true, $cat_relation);
     }
     $nav_layout = $base->getVar($this->grid_params, 'navigation-layout', array());
     $nav_skin = $base->getVar($this->grid_params, 'navigation-skin', 'minimal-light');
     $hover_animation = $base->getVar($this->grid_params, 'hover-animation', 'fade');
     $filter_allow = $base->getVar($this->grid_params, 'filter-arrows', 'single');
     $filter_start = $base->getVar($this->grid_params, 'filter-start', '');
     $nav_type = $base->getVar($this->grid_params, 'nagivation-type', 'internal');
     $do_nav = $nav_type == 'internal' ? true : false;
     $order_by = explode(',', $base->getVar($this->grid_params, 'sorting-order-by', 'date'));
     if (!is_array($order_by)) {
         $order_by = array($order_by);
     }
     $order_by_start = $base->getVar($this->grid_params, 'sorting-order-by-start', 'none');
     if (strpos($order_by_start, 'eg-') === 0 || strpos($order_by_start, 'egl-') === 0) {
         //add meta at the end for meta sorting
         //if essential Meta, replace to meta name. Else -> replace - and _ with space, set each word uppercase
         $metas = $m->get_all_meta();
         $f = false;
         if (!empty($metas)) {
             foreach ($metas as $meta) {
                 if ('eg-' . $meta['handle'] == $order_by_start || 'egl-' . $meta['handle'] == $order_by_start) {
                     $f = true;
                     $order_by_start = $meta['name'];
                     break;
                 }
             }
         }
         if ($f === false) {
//.........这里部分代码省略.........
开发者ID:kfwebdev,项目名称:wp-atd,代码行数:101,代码来源:essential-grid.class.php


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