Guest User

Untitled

a guest
Sep 26th, 2014
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.09 KB | None | 0 0
  1. <?php
  2. /* Template Name: Homepage - with article list */
  3.  
  4.  
  5.  
  6.  
  7.  
  8. get_header();
  9.  
  10.  
  11. td_global::$current_template = 'page-homepage-loop';
  12.  
  13. global $paged, $loop_module_id, $loop_sidebar_position, $post, $more; //$more is a hack to fix the read more loop
  14. $td_page = (get_query_var('page')) ? get_query_var('page') : 1; //rewrite the global var
  15. $td_paged = (get_query_var('paged')) ? get_query_var('paged') : 1; //rewrite the global var
  16.  
  17.  
  18. //paged works on single pages, page - works on homepage
  19. if ($td_paged > $td_page) {
  20. $paged = $td_paged;
  21. } else {
  22. $paged = $td_page;
  23. }
  24.  
  25.  
  26. $list_custom_title_show = true; //show the article list title by default
  27.  
  28.  
  29.  
  30. $td_homepage_loop_filter = ''; //homepage loop filter metadata
  31.  
  32. /*
  33. read the settings for the loop
  34. ---------------------------------------------------------------------------------------- */
  35. if (!empty($post->ID)) {
  36. td_global::load_single_post($post);
  37. //read the metadata for the post
  38. $td_homepage_loop_filter = get_post_meta($post->ID, 'td_homepage_loop_filter', true); //it's send to td_data_source
  39. $td_homepage_loop = get_post_meta($post->ID, 'td_homepage_loop', true);
  40.  
  41.  
  42. if (!empty($td_homepage_loop['td_layout'])) {
  43. $loop_module_id = $td_homepage_loop['td_layout'];
  44. }
  45.  
  46. if (!empty($td_homepage_loop['td_sidebar_position'])) {
  47. $loop_sidebar_position = $td_homepage_loop['td_sidebar_position'];
  48. }
  49.  
  50. if (!empty($td_homepage_loop['td_sidebar'])) {
  51. td_global::$load_sidebar_from_template = $td_homepage_loop['td_sidebar'];
  52. }
  53.  
  54. if (!empty($td_homepage_loop['list_custom_title'])) {
  55. $td_list_custom_title = $td_homepage_loop['list_custom_title'];
  56. } else {
  57. $td_list_custom_title =__td('LATEST ARTICLES');
  58. }
  59.  
  60.  
  61. if (!empty($td_homepage_loop['list_custom_title_show'])) {
  62. $list_custom_title_show = false;
  63. }
  64. }
  65.  
  66.  
  67. echo td_page_generator::wrap_no_row_start();
  68. /*
  69. the first part of the page (built with the page builder) - empty($paged) or $paged < 2 = first page
  70. ---------------------------------------------------------------------------------------- */
  71. if(!empty($post->post_content)) { //show this only when we have content
  72. if (empty($paged) or $paged < 2) { //show this only on the first page
  73.  
  74. ?>
  75. <div class="row-fluid">
  76. <div class="span12 column_container" role="complementary" itemscope="itemscope" itemtype="<?php echo td_global::$http_or_https?>://schema.org/WPSideBar">
  77. <?php
  78. if (have_posts()) {
  79. while ( have_posts() ) : the_post();
  80. //read the page settings
  81. the_content();
  82. endwhile; //end loop
  83. }
  84. ?>
  85. </div>
  86. </div>
  87. <?php
  88.  
  89. }
  90. }
  91.  
  92.  
  93. /*
  94. the main fake loop
  95. ---------------------------------------------------------------------------------------- */
  96.  
  97. $more = 0; // fix read more
  98.  
  99. echo '<div class="row-fluid">';
  100.  
  101. switch ($loop_sidebar_position) {
  102.  
  103.  
  104. case 'sidebar_left':
  105. ?>
  106. <div class="span4 column_container" role="complementary" itemscope="itemscope" itemtype="<?php echo td_global::$http_or_https?>://schema.org/WPSideBar">
  107. <?php get_sidebar(); ?>
  108. </div>
  109. <div class="span8 column_container" role="main" itemprop="mainContentOfPage" itemscope="itemscope" itemtype="<?php echo td_global::$http_or_https?>://schema.org/Blog">
  110. <?php if ((empty($paged) or $paged < 2) and $list_custom_title_show === true) { ?>
  111. <h4 class="block-title"><span><?php echo $td_list_custom_title?></span></h4>
  112. <?php }
  113. query_posts(td_data_source::metabox_to_args($td_homepage_loop_filter, $paged));
  114. locate_template('loop.php', true);
  115. //echo td_page_generator::get_pagination();
  116. ?> <div class="td-older-pagination"><?php next_posts_link('OLDER POSTS'); ?></div> <?php
  117. wp_reset_query();
  118. ?>
  119. </div>
  120. <?php
  121. break;
  122.  
  123.  
  124. case 'no_sidebar':
  125. ?>
  126. <div class="span12 column_container" role="main" itemprop="mainContentOfPage" itemscope="itemscope" itemtype="<?php echo td_global::$http_or_https?>://schema.org/Blog">
  127. <?php if ((empty($paged) or $paged < 2) and $list_custom_title_show === true) { ?>
  128. <h4 class="block-title"><span><?php echo $td_list_custom_title?></span></h4>
  129. <?php }
  130.  
  131. query_posts(td_data_source::metabox_to_args($td_homepage_loop_filter, $paged));
  132. locate_template('loop.php', true);
  133. // echo td_page_generator::get_pagination();
  134. ?> <div class="td-older-pagination"><?php next_posts_link('OLDER POSTS'); ?></div> <?php
  135. wp_reset_query();
  136. ?>
  137. </div>
  138. <?php
  139. break;
  140.  
  141.  
  142. //sidebar right
  143. default:
  144. ?>
  145. <div class="span8 column_container" role="main" itemprop="mainContentOfPage" itemscope="itemscope" itemtype="<?php echo td_global::$http_or_https?>://schema.org/Blog">
  146. <?php if ((empty($paged) or $paged < 2) and $list_custom_title_show === true) { ?>
  147. <h4 class="block-title"><span><?php echo $td_list_custom_title?></span></h4>
  148. <?php }
  149.  
  150. //
  151. query_posts(td_data_source::metabox_to_args($td_homepage_loop_filter, $paged));
  152. locate_template('loop.php', true);
  153. // echo td_page_generator::get_pagination();
  154. ?> <div class="td-older-pagination"><?php next_posts_link('OLDER POSTS'); ?></div> <?php
  155. wp_reset_query();
  156. ?>
  157. </div>
  158. <div class="span4 column_container" role="complementary" itemscope="itemscope" itemtype="<?php echo td_global::$http_or_https?>://schema.org/WPSideBar">
  159. <?php get_sidebar(); ?>
  160. </div>
  161. <?php
  162. break;
  163. }
  164.  
  165.  
  166. echo '</div>'; //close the .row
  167. echo td_page_generator::wrap_no_row_end();
  168.  
  169.  
  170.  
  171. get_footer();
  172. ?>
Advertisement
Add Comment
Please, Sign In to add comment