Guest User

Untitled

a guest
Oct 16th, 2015
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.68 KB | None | 0 0
  1. <?php
  2.  
  3. class td_block_1 extends td_block {
  4.  
  5.  
  6.  
  7. function render($atts, $content = null) {
  8. parent::render($atts); // sets the live atts, $this->atts, $this->block_uid, $this->td_query (it runs the query)
  9.  
  10. $buffy = ''; //output buffer
  11.  
  12. //get the js for this block
  13. $buffy .= $this->get_block_js();
  14.  
  15. $buffy .= '<div class="' . $this->get_block_classes() . '">';
  16.  
  17. //get the block title
  18. $buffy .= $this->get_block_title();
  19.  
  20.  
  21. //get the sub category filter for this block
  22. $buffy .= $this->get_pull_down_filter();
  23.  
  24. $buffy .= '<div id=' . $this->block_uid . ' class="td_block_inner">';
  25. $buffy .= $this->inner($this->td_query->posts);//inner content of the block
  26. $buffy .= '</div>';
  27.  
  28. //get the ajax pagination for this block
  29. $buffy .= $this->get_block_pagination();
  30. $buffy .= '</div> <!-- ./block -->';
  31. return $buffy;
  32. }
  33.  
  34. function inner($posts, $td_column_number = '') {
  35.  
  36. $buffy = '';
  37.  
  38. $td_block_layout = new td_block_layout();
  39.  
  40. if (empty($td_column_number)) {
  41. $td_column_number = td_util::vc_get_column_number(); // get the column width of the block from the page builder API
  42. }
  43.  
  44.  
  45. $td_post_count = 0; // the number of posts rendered
  46.  
  47. if (!empty($posts)) {
  48. foreach ($posts as $post) {
  49. $td_module_4 = new td_module_4($post);
  50. $td_module_6 = new td_module_6($post);
  51.  
  52. switch ($td_column_number) {
  53.  
  54. case '1': //one column layout
  55. $buffy .= $td_block_layout->open12(); //added in 010 theme - span 12 doesn't use rows
  56. if ($td_post_count == 0) { //first post
  57. $buffy .= $td_module_4->render();
  58. } else {
  59. $buffy .= $td_module_6->render();
  60. }
  61. $buffy .= $td_block_layout->close12();
  62. break;
  63.  
  64. case '2': //two column layout
  65. $buffy .= $td_block_layout->open_row();
  66. if ($td_post_count <= 3) { //first post
  67. $buffy .= $td_block_layout->open6();
  68. $buffy .= $td_module_6->render();
  69. if ($td_post_count == 3) {
  70. $buffy .= $td_block_layout->close6();
  71. }
  72. } else { //the rest
  73. $buffy .= $td_block_layout->open6();
  74. $buffy .= $td_module_4->render();
  75. }
  76. break;
  77.  
  78. case '3': //three column layout
  79. $buffy .= $td_block_layout->open_row();
  80. if ($td_post_count == 0) { //first post
  81. $buffy .= $td_block_layout->open4();
  82. $buffy .= $td_module_4->render();
  83. $buffy .= $td_block_layout->close4();
  84. } else { //2-3 cols
  85. $buffy .= $td_block_layout->open4();
  86. $buffy .= $td_module_6->render();
  87.  
  88. if ($td_post_count == 4) { //make new column
  89. $buffy .= $td_block_layout->close4();
  90. }
  91. }
  92. break;
  93. }
  94. $td_post_count++;
  95. }
  96.  
  97. }
  98. $buffy .= $td_block_layout->close_all_tags();
  99. return $buffy;
  100. }
  101. }
Advertisement
Add Comment
Please, Sign In to add comment