1. <?php
  2. /*
  3. * @template Mystique
  4. * @revised December 20, 2011
  5. * @author digitalnature, http://digitalnature.eu
  6. * @license GPL, http://www.opensource.org/licenses/gpl-license
  7. */
  8. // Display one post per category + 5 links to the next 5 posts.
  9. // This is a custom page template that can be applied to individual pages.
  10. /* Template Name: Categories */
  11. ?>
  12. <?php
  13. // force gettext parsers to include this string
  14. if(true === false)
  15. atom()->t('Categories');
  16. atom()->template('header');
  17. // if a different taxonomy is used, replace the 'category' argument below with the taxonomy slug
  18. $terms = get_terms($tax = 'category');
  19. // get the posts
  20. $main_posts = $next_posts = array();
  21. foreach($terms as $term){
  22. $results = get_posts(array(
  23. 'numberposts' => 6, // one main post per category + 5 titles
  24. 'category' => $term->term_id, // the category ID
  25. ));
  26. // main post
  27. if($results)
  28. $main_posts[$term->term_id] = array_shift($results);
  29. // if we have more, retrieve title and url for additional posts
  30. if($results)
  31. foreach($results as $post){
  32. atom()->post = $post; // sets up post data (stupid WP globals)
  33. $next_posts[$term->term_id][] = array(
  34. 'title' => atom()->post->getTitle(),
  35. 'url' => atom()->post->getURL(),
  36. );
  37. }
  38. }
  39. atom()->resetCurrentPost();
  40. ?>
  41. <!-- main content: primary + sidebar(s) -->
  42. <div id="mask-3" class="clear-block">
  43. <div id="mask-2">
  44. <div id="mask-1">
  45. <!-- primary content -->
  46. <div id="primary-content">
  47. <div class="blocks clear-block">
  48. <?php atom()->action('before_primary'); ?>
  49. <?php the_post(); ?>
  50. <?php atom()->action('before_post'); ?>
  51. <!-- user page content -->
  52. <div id="post-<?php the_ID(); ?>" <?php post_class('primary'); ?>>
  53. <?php if(!atom()->post->getMeta('hide_title')): ?>
  54. <h1 class="title"><?php the_title(); ?></h1>
  55. <?php endif; ?>
  56. <!-- START TESTE -->
  57. <?php
  58. $args = array(
  59. 'exclude'=> array(1,3,4,5,6)
  60. );
  61. $categories = get_categories($args);
  62. foreach ($categories as $cat) {
  63. if ($cat->category_parent != 0) {
  64. echo '<span style="padding-left:10px;">';
  65. }
  66. echo '<a href="'.get_option('home').get_option('category_base').'/'.$cat->category_nicename.'/">'.$cat->cat_name.'</a> ('.$cat->category_count.')';
  67. if ($cat->category_description != '') {
  68. echo ' - '.$cat->category_description;
  69. }
  70. if ($cat->category_parent != 0) {
  71. echo '</span>';
  72. }
  73. echo '<br /><br /><br />';
  74. }
  75. ?>
  76. <!-- END TESTE -->
  77. <div class="clear-block">
  78. <?php the_content(); ?>
  79. </div>
  80. <?php atom()->post->pagination(); ?>
  81. <?php atom()->controls('post-edit'); ?>
  82. </div>
  83. <!-- /user page content -->
  84. <?php atom()->action('after_post'); ?>
  85. <?php if(empty($main_posts)): // we don't have any posts, display the message ?>
  86. <h2 class="title error"><?php atom()->te('Oops, nothing here :('); ?></h2>
  87. <?php else: ?>
  88. <?php foreach($terms as $term): ?>
  89. <?php if(empty($main_posts[$term->term_id])) continue; ?>
  90. <h5 class="title"><?php echo $term->name; ?></h5>
  91. <?php atom()->post = $main_posts[$term->term_id]; // sets up the post data ?>
  92. <?php atom()->action('before_post'); ?>
  93. <!-- post -->
  94. <div id="post-<?php the_ID(); ?>" <?php post_class('thumb-left'); ?>>
  95. <a class="post-thumb" href="<?php atom()->post->URL(); ?>" title="<?php atom()->post->title(); ?>">
  96. <?php atom()->post->thumbnail(); ?>
  97. </a>
  98. <!-- next posts -->
  99. <?php if(!empty($next_posts[$term->term_id])): ?>
  100. <div class="block alignright" style="width: 200px;">
  101. <ul class="menu fadeThis">
  102. <?php foreach($next_posts[$term->term_id] as $post): ?>
  103. <li><a href="<?php echo $post['url']; ?>"><?php echo $post['title']; ?></a></li>
  104. <?php endforeach; ?>
  105. </ul>
  106. </div>
  107. <?php endif; ?>
  108. <!-- //next posts -->
  109. <h2 class="title"><a href="<?php atom()->post->URL(); ?>"><?php atom()->post->title(); ?></a></h2>
  110. <div class="post-details clear-block">
  111. <p>
  112. <?php
  113. // main post content
  114. atom()->post->content($limit = 500, array(
  115. 'cutoff' => 'word',
  116. 'more_inline' => true,
  117. 'allowed_tags' => 'a,abbr,acronym,b,cite,code,del,dfn,em,i,ins,q,strong,sub,sup', // inline tags only, because the space is limited
  118. ));
  119. ?>
  120. </p>
  121. </div>
  122. <?php atom()->controls('post-edit'); ?>
  123. </div>
  124. <!-- /post -->
  125. <?php atom()->action('after_post'); ?>
  126. <?php atom()->resetCurrentPost(); ?>
  127. <?php endforeach; ?>
  128. <?php endif; ?>
  129. <?php atom()->action('after_primary'); ?>
  130. </div>
  131. </div>
  132. <!-- /primary content -->
  133. <?php atom()->template('sidebar'); ?>
  134. </div>
  135. </div>
  136. </div>
  137. <!-- /main content -->
  138. <?php atom()->template('footer'); ?>