Guest User

Untitled

a guest
Nov 19th, 2014
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.76 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.  
  70. /*
  71. the main fake loop
  72. ---------------------------------------------------------------------------------------- */
  73.  
  74. $more = 0; // fix read more
  75.  
  76. echo '<div class="row-fluid">';
  77.  
  78. switch ($loop_sidebar_position) {
  79.  
  80.  
  81. case 'sidebar_left':
  82. ?>
  83. <div class="span4 column_container" role="complementary" itemscope="itemscope" itemtype="<?php echo td_global::$http_or_https?>://schema.org/WPSideBar">
  84. <?php get_sidebar(); ?>
  85. </div>
  86. <div class="span8 column_container" role="main" itemprop="mainContentOfPage" itemscope="itemscope" itemtype="<?php echo td_global::$http_or_https?>://schema.org/Blog">
  87. <?php if ((empty($paged) or $paged < 2) and $list_custom_title_show === true) { ?>
  88. <h4 class="block-title"><span><?php echo $td_list_custom_title?></span></h4>
  89. <?php }
  90. query_posts(td_data_source::metabox_to_args($td_homepage_loop_filter, $paged));
  91. locate_template('loop.php', true);
  92. echo td_page_generator::get_pagination();
  93. wp_reset_query();
  94. ?>
  95. </div>
  96. <?php
  97. break;
  98.  
  99.  
  100. case 'no_sidebar':
  101. ?>
  102. <div class="span12 column_container" role="main" itemprop="mainContentOfPage" itemscope="itemscope" itemtype="<?php echo td_global::$http_or_https?>://schema.org/Blog">
  103. <?php if ((empty($paged) or $paged < 2) and $list_custom_title_show === true) { ?>
  104. <h4 class="block-title"><span><?php echo $td_list_custom_title?></span></h4>
  105. <?php }
  106.  
  107. query_posts(td_data_source::metabox_to_args($td_homepage_loop_filter, $paged));
  108. locate_template('loop.php', true);
  109. echo td_page_generator::get_pagination();
  110. wp_reset_query();
  111. ?>
  112. </div>
  113. <?php
  114. break;
  115.  
  116.  
  117. //sidebar right
  118. default:
  119. ?>
  120. <div class="span8 column_container" role="main" itemprop="mainContentOfPage" itemscope="itemscope" itemtype="<?php echo td_global::$http_or_https?>://schema.org/Blog">
  121. <?php if ((empty($paged) or $paged < 2) and $list_custom_title_show === true) { ?>
  122. <h4 class="block-title"><span><?php echo $td_list_custom_title?></span></h4>
  123. <?php }
  124.  
  125. //
  126. query_posts(td_data_source::metabox_to_args($td_homepage_loop_filter, $paged));
  127. locate_template('loop.php', true);
  128. echo td_page_generator::get_pagination();
  129. wp_reset_query();
  130. ?>
  131. </div>
  132. <div class="span4 column_container" role="complementary" itemscope="itemscope" itemtype="<?php echo td_global::$http_or_https?>://schema.org/WPSideBar">
  133. <?php get_sidebar(); ?>
  134. </div>
  135. <?php
  136. break;
  137. }
  138.  
  139.  
  140. echo '</div>'; //close the .row
  141.  
  142. /*
  143. the first part of the page (built with the page builder) - empty($paged) or $paged < 2 = first page
  144. ---------------------------------------------------------------------------------------- */
  145. if(!empty($post->post_content)) { //show this only when we have content
  146. if (empty($paged) or $paged < 2) { //show this only on the first page
  147.  
  148. ?>
  149. <div class="row-fluid">
  150. <div class="span12 column_container" role="complementary" itemscope="itemscope" itemtype="<?php echo td_global::$http_or_https?>://schema.org/WPSideBar">
  151. <?php
  152. if (have_posts()) {
  153. while ( have_posts() ) : the_post();
  154. //read the page settings
  155. the_content();
  156. endwhile; //end loop
  157. }
  158. ?>
  159. </div>
  160. </div>
  161. <?php
  162.  
  163. }
  164. }
  165.  
  166. echo td_page_generator::wrap_no_row_end();
  167.  
  168.  
  169.  
  170. get_footer();
  171. ?>
Advertisement
Add Comment
Please, Sign In to add comment