function render($atts, $content = null) { $atts['limit'] = 5; parent::render($atts); // sets the live atts, $this->atts, $this->block_uid, $this->td_query (it runs the query) if (is_category()) { // we have no related posts to display if ($this->td_query->post_count == 0) { return '<div class="td_line_above_cat_big_grid"> </div>'; } /** if we have posts in the big grid and we are on a category, do not show the default page no posts message. @see td_global::$custom_no_posts_message */ td_global::$custom_no_posts_message = false; } $buffy = ''; //output buffer //get the js for this block $buffy .= $this->get_block_js(); $buffy .= '<div class="' . $this->get_block_classes() . '">'; //get the block title $buffy .= $this->get_block_title(); //get the sub category filter for this block $buffy .= $this->get_pull_down_filter(); $buffy .= '<div id=' . $this->block_uid . ' class="td_block_inner">'; $buffy .= $this->inner($this->td_query->posts); //inner content of the block $buffy .= '</div>'; //get the ajax pagination for this block $buffy .= $this->get_block_pagination(); $buffy .= '</div> <!-- ./block -->'; $buffy .= '<div class="clearfix"></div>'; return $buffy; }
/** * we have to render the block first in the buffer, to avoid two queries. * - IF there are posts, we already have the buffer with the block's content and we don't have to make another query * - IF there are no posts, we ignore the buffer and we can also remove the wraps in the child classes of this class */ protected function render_posts_to_buffer() { // get the global category top posts grid style setting $td_grid_style = td_util::get_option('tds_category_td_grid_style'); $limit = td_api_category_top_posts_style::_helper_get_posts_shown_in_the_loop(); $block_name = td_api_category_top_posts_style::get_key(get_class($this), 'td_block_name'); // overwrite the $td_grid_style if the setting for this category was changed $td_grid_style_per_category_setting = td_util::get_category_option(td_global::$current_category_obj->cat_ID, 'tdc_category_td_grid_style'); if ($td_grid_style_per_category_setting != '') { $td_grid_style = $td_grid_style_per_category_setting; } // we have to have a default grid, there seems to be a problem with the grid styles if (empty($td_grid_style)) { $td_grid_style = 'td-grid-style-1'; } //parameters to filter to for big grid $atts_for_big_grid = array('limit' => $limit, 'category_id' => td_global::$current_category_obj->cat_ID, 'sort' => get_query_var('filter_by'), 'td_grid_style' => $td_grid_style); //show the big grid $block_instance = td_global_blocks::get_instance($block_name); $this->rendered_block_buffer = $block_instance->render($atts_for_big_grid); $this->rendered_posts_count = $block_instance->td_query->post_count; if ($this->rendered_posts_count > 0) { td_global::$custom_no_posts_message = false; } // use class_name($this) to get the id :) }
get_header(); //set the template id, used to get the template specific settings $template_id = 'search'; //prepare the loop variables global $loop_module_id, $loop_sidebar_position; /* after */ $loop_module_id = td_util::get_option('tds_' . $template_id . '_page_layout', 16); //module 16 is default $loop_sidebar_position = td_util::get_option('tds_' . $template_id . '_sidebar_pos'); //sidebar right is default (empty) // sidebar position used to align the breadcrumb on sidebar left + sidebar first on mobile issue $td_sidebar_position = ''; if ($loop_sidebar_position == 'sidebar_left') { $td_sidebar_position = 'td-sidebar-left'; } td_global::$custom_no_posts_message = __td('No results for your search', TD_THEME_NAME); ?> <div class="td-main-content-wrap"> <div class="td-container <?php echo $td_sidebar_position; ?> "> <div class="td-crumb-container"> <?php echo td_page_generator::get_search_breadcrumbs(); ?> </div> <div class="td-pb-row"> <?php switch ($loop_sidebar_position) {