function inner($posts, $td_column_number = '') { $buffy = ''; $td_block_layout = new td_block_layout(); $td_post_count = 0; // the number of posts rendered $td_current_column = 1; //the current column if (!empty($posts)) { foreach ($posts as $post) { $td_module_mx8 = new td_module_mx8($post); $td_module_10 = new td_module_10($post); $td_module_mx2 = new td_module_mx2($post); switch ($td_column_number) { case '1': //one column layout if ($td_post_count == 0) { //first post $buffy .= $td_module_mx8->render(); } else { $buffy .= $td_module_mx2->render(); } break; case '2': //two column layout if ($td_post_count == 0) { // big posts $buffy .= $td_module_mx8->render(); } else { $buffy .= $td_module_10->render(); } break; case '3': //three column layout if ($td_post_count == 0) { // big posts $buffy .= $td_module_mx8->render(); } else { $buffy .= $td_module_10->render(); } break; } //current column if ($td_current_column == $td_column_number) { $td_current_column = 1; } else { $td_current_column++; } $td_post_count++; } } $buffy .= $td_block_layout->close_all_tags(); return $buffy; }
function inner($posts, $td_column_number = '') { $buffy = ''; $td_block_layout = new td_block_layout(); if (empty($td_column_number)) { $td_column_number = td_util::vc_get_column_number(); // get the column width of the block from the page builder API } $td_post_count = 0; // the number of posts rendered $td_current_column = 1; //the current column if (!empty($posts)) { foreach ($posts as $post) { $td_module_mx1 = new td_module_mx1($post); $td_module_mx2 = new td_module_mx2($post); switch ($td_column_number) { case '1': //one column layout $buffy .= $td_block_layout->open12(); //added in 010 theme - span 12 doesn't use rows if ($td_post_count == 0) { //first post $buffy .= $td_module_mx1->render(); } else { $buffy .= $td_module_mx2->render(); } $buffy .= $td_block_layout->close12(); break; case '2': //two column layout $buffy .= $td_block_layout->open_row(); if ($td_post_count <= 1) { // big posts $buffy .= $td_block_layout->open6(); $buffy .= $td_module_mx1->render(); $buffy .= $td_block_layout->close6(); } if ($td_post_count == 1) { //close big posts $buffy .= $td_block_layout->close_row(); } if ($td_post_count > 1) { //4th post (big posts are rendered) if ($td_current_column == 1) { // column 1 $buffy .= $td_block_layout->open_row(); } $buffy .= $td_block_layout->open6(); $buffy .= $td_module_mx2->render(); $buffy .= $td_block_layout->close6(); if ($td_current_column == 2) { // column 2 $buffy .= $td_block_layout->close_row(); } } break; case '3': //three column layout $buffy .= $td_block_layout->open_row(); if ($td_post_count <= 2) { // big posts $buffy .= $td_block_layout->open4(); $buffy .= $td_module_mx1->render(); $buffy .= $td_block_layout->close4(); } if ($td_post_count == 2) { //close big posts $buffy .= $td_block_layout->close_row(); } if ($td_post_count > 2) { //4th post (big posts are rendered) if ($td_current_column == 1) { // column 1 $buffy .= $td_block_layout->open_row(); } $buffy .= $td_block_layout->open4(); $buffy .= $td_module_mx2->render(); $buffy .= $td_block_layout->close4(); if ($td_current_column == 3) { // column 3 $buffy .= $td_block_layout->close_row(); } } break; } //current column if ($td_current_column == $td_column_number) { $td_current_column = 1; } else { $td_current_column++; } $td_post_count++; } } $buffy .= $td_block_layout->close_all_tags(); return $buffy; }
function td_ajax_search() { $buffy = ''; $buffy_msg = ''; //the search string if (!empty($_POST['td_string'])) { $td_string = $_POST['td_string']; } else { $td_string = ''; } //get the data $td_query =& td_data_source::get_wp_query_search($td_string); //by ref do the query //build the results if (!empty($td_query->posts)) { foreach ($td_query->posts as $post) { $td_module_mx2 = new td_module_mx2($post); $buffy .= $td_module_mx2->render(); } } if (count($td_query->posts) == 0) { //no results $buffy = '<div class="result-msg no-result">' . __td('No results', TD_THEME_NAME) . '</div>'; } else { //show the resutls /** * @note: * we use esc_url(home_url( '/' )) instead of the WordPress @see get_search_link function because that's what the internal * WordPress widget it's using and it was creating duplicate links like: yoursite.com/search/search_query and yoursite.com?s=search_query */ $buffy_msg .= '<div class="result-msg"><a href="' . esc_url(home_url('/?s=' . $td_string)) . '">' . __td('View all results', TD_THEME_NAME) . '</a></div>'; //add wrap $buffy = '<div class="td-aj-search-results">' . $buffy . '</div>' . $buffy_msg; } //prepare array for ajax $buffyArray = array('td_data' => $buffy, 'td_total_results' => 2, 'td_total_in_list' => count($td_query->posts), 'td_search_query' => $td_string); // Return the String die(json_encode($buffyArray)); }
function inner($posts, $td_column_number = '') { $buffy = ''; $td_block_layout = new td_block_layout(); $td_post_count = 0; // the number of posts rendered $td_current_column = 1; //the current column if (!empty($posts)) { foreach ($posts as $post) { $td_module_mx1 = new td_module_mx1($post); $td_module_mx2 = new td_module_mx2($post); switch ($td_column_number) { case '1': //one column layout if ($td_post_count == 0) { //first post $buffy .= $td_module_mx1->render(); } else { $buffy .= $td_module_mx2->render(); } break; case '2': //two column layout $buffy .= $td_block_layout->open_row(); if ($td_post_count <= 1) { // big posts $buffy .= $td_block_layout->open6(); $buffy .= $td_module_mx1->render(); $buffy .= $td_block_layout->close6(); } if ($td_post_count == 1) { //close big posts $buffy .= $td_block_layout->close_row(); } if ($td_post_count > 1) { //4th post (big posts are rendered) $buffy .= $td_block_layout->open_row(); $buffy .= $td_block_layout->open6(); $buffy .= $td_module_mx2->render(); $buffy .= $td_block_layout->close6(); if ($td_current_column == 2) { // column 2 $buffy .= $td_block_layout->close_row(); } } break; case '3': //three column layout $buffy .= $td_block_layout->open_row(); if ($td_post_count <= 2) { // big posts $buffy .= $td_block_layout->open4(); $buffy .= $td_module_mx1->render(); $buffy .= $td_block_layout->close4(); } if ($td_post_count == 2) { //close big posts $buffy .= $td_block_layout->close_row(); } if ($td_post_count > 2) { //4th post (big posts are rendered) $buffy .= $td_block_layout->open_row(); $buffy .= $td_block_layout->open4(); $buffy .= $td_module_mx2->render(); $buffy .= $td_block_layout->close4(); if ($td_current_column == 3) { // column 3 $buffy .= $td_block_layout->close_row(); } } break; } //current column if ($td_current_column == $td_column_number) { $td_current_column = 1; } else { $td_current_column++; } $td_post_count++; } } $buffy .= $td_block_layout->close_all_tags(); return $buffy; }