~peterm-ubuntu/resource-centre/rest-fix

14.1.1 by Graham Bancroft
Mobile beta
1
<?php
2
3
// Exit if accessed directly
4
if ( !defined('ABSPATH')) exit;
5
6
/**
7
 * Category Template
8
 *
9
 *
10
 * @file           taxonomy-topic.php
11
 * @package        Ubuntu blog theme 
12
 * @author         Canonical Web Team 
13
 * @copyright      2012 Canonical Ltd
14
 * @license
15
 * @version        Release: 1.0
16
 * @filesource     wp-content/themes/insights-theme/category.php
17
 * @link           http://codex.wordpress.org/Theme_Development#Archive_.28category.php.29
18
 * @since          available since Release 1.0
19
 */
20
 
21
 /* Template Name: Topics */
22
?>
23
24
<?php get_header(); 
25
	$paged = (get_query_var('paged')) ? get_query_var('paged') : 1; // Needed for pagination
26
	$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
27
	$tax = get_query_var( 'taxonomy' );
28
	$post = $wp_query->get_queried_object();
29
	$current_tax = basename(get_permalink());
30
?>
20 by Graham Bancroft
Tablet updates
31
	
14.1.1 by Graham Bancroft
Mobile beta
32
<?php
33
/* ============== pull in business card ============== */
34
  wp_reset_query();
35
	$paged = (get_query_var('paged')) ? get_query_var('paged') : 1; // Needed for pagination
36
	$query = new WP_Query( array(
54 by Graham Bancroft
Phase 2 updates
37
	  'posts_per_page'  => 1,
38
    'topic'           => $current_tax,
39
    'post_type'       => 'productbusinesscard',
40
    'post_status'     => 'publish',
41
    'post__not_in'    => $do_not_duplicate,
42
    'paged'           => $paged
14.1.1 by Graham Bancroft
Mobile beta
43
	));
49 by Graham Bancroft
Impliment new design
44
45
    if ($query->have_posts()) :
14.1.1 by Graham Bancroft
Mobile beta
46
	while( $query->have_posts() ): 
47
	$query->the_post(); 
48
	$do_not_duplicate[] = $post->ID ?>
54 by Graham Bancroft
Phase 2 updates
49
    <div class="row glossary-box glossary-box-<?php echo strtolower(wp_title( '', false, 'right' )); ?> no-border">
49 by Graham Bancroft
Impliment new design
50
        <div class="inner-wrapper">
67 by Graham Bancroft
Add RTP IDs
51
            <div id="rtp-banner" class="six-col">
49 by Graham Bancroft
Impliment new design
52
                <h1><?php wp_title(''); ?></h1>
67 by Graham Bancroft
Add RTP IDs
53
                <div id="rtp-banner"><?php the_content(); ?></div>
49 by Graham Bancroft
Impliment new design
54
            </div>
55
            <div class="last-col">
56
            </div>
57
        </div>
58
    </div>
14.1.1 by Graham Bancroft
Mobile beta
59
60
<?php endwhile; ?>
61
62
<?php endif; // if have_posts ends 
49 by Graham Bancroft
Impliment new design
63
/* ============== end pull in business card ============== */ ?>
14.1.1 by Graham Bancroft
Mobile beta
64
54 by Graham Bancroft
Phase 2 updates
65
<?php 
66
/* ============== pull in featured ============== */
14.1.1 by Graham Bancroft
Mobile beta
67
	$paged = (get_query_var('paged')) ? get_query_var('paged') : 1; // Needed for pagination
68
	$query = new WP_Query( array(
54 by Graham Bancroft
Phase 2 updates
69
	  'posts_per_page'  => 1,
70
    'topic'           => $current_tax,
71
    'post_type'       => 'post',
101.1.1 by Thomas Bille
Remove feature custom feature
72
      'paged'           => $paged,
73
      'post__in'  => get_option( 'sticky_posts' ),
74
      'ignore_sticky_posts' => 1
14.1.1 by Graham Bancroft
Mobile beta
75
	));
76
?>
49 by Graham Bancroft
Impliment new design
77
<div class="row">
78
<div class="inner-wrapper">
79
<div class="eight-col no-margin-bottom">
14.1.1 by Graham Bancroft
Mobile beta
80
<?php if ($query->have_posts()) : ?>
49 by Graham Bancroft
Impliment new design
81
    <div class="featured box box-highlight eight-col">
82
        <h2>Featured</h2>
83
        <?php 
84
        	while( $query->have_posts() ): 
85
        	$query->the_post(); 
86
        	$do_not_duplicate[] = $post->ID ?>
87
            <?php get_template_part("content_home_featured"); ?>	
88
        <?php endwhile; ?>
89
    </div><!-- /.box -->
14.1.1 by Graham Bancroft
Mobile beta
90
<?php else : ?>	
91
<?php 
92
// The Query
93
	$new_query = new WP_Query( array(
54 by Graham Bancroft
Phase 2 updates
94
	  'posts_per_page'  => 1,
95
    'topic'           => $current_tax,
96
    'post_type'       => 'post',
97
    'paged'           => $paged
14.1.1 by Graham Bancroft
Mobile beta
98
	));
99
?>
49 by Graham Bancroft
Impliment new design
100
<?php while( $new_query->have_posts() ): $new_query->the_post(); ?>
101
	<?php if ('event' == get_post_type()) : ?>
102
		<?php get_template_part("includes/_event_meta"); ?>
103
	<?php else : ?>
104
		<?php get_template_part("content_home"); ?>	
105
	<?php endif ; ?>
106
<?php endwhile; wp_reset_postdata(); ?>
14.1.1 by Graham Bancroft
Mobile beta
107
<?php endif; // if have_posts ends 
108
/* ============== end pull in featured ============== */
109
?>
110
111
<?php
49 by Graham Bancroft
Impliment new design
112
/* ============== pull in latest articles ============== */
113
wp_reset_query();
114
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1; // Needed for pagination
115
$current_tax = basename(get_permalink());
116
$exclude_cat ='downloads';
117
$category = get_category_by_slug($exclude_cat);
118
$query = new WP_Query( array(
54 by Graham Bancroft
Phase 2 updates
119
	'posts_per_page'  => 4,
120
	'topic'           => $current_tax,
121
	'cat'             => -$category->cat_ID,
122
  'post_type'       => 'post',
123
  'post__not_in'    => $do_not_duplicate,
124
	'paged'           => $paged
49 by Graham Bancroft
Impliment new design
125
));
41 by Graham Bancroft
Move events to the bottom of the page. Change latest news to show latest everything.
126
?>
127
 
128
<?php if ($query->have_posts()) : ?>
49 by Graham Bancroft
Impliment new design
129
<div class="box box-highlight eight-col clear">
130
	<h2>Latest in <?php echo wp_title( '', false, 'right' ); ?><!--<span><?php echo strtolower(wp_title( '', false, 'right' )); ?></span> news --></h2>
131
	<ul class="no-bullets">
132
	<?php 
133
		while( $query->have_posts() ): 
134
		$query->the_post(); 
135
		$do_not_duplicate[] = $post->ID ?>
136
        <li class="eight-col"><?php get_template_part("content_home"); ?>	</li>
137
	<?php endwhile; ?>
138
	</ul>
139
</div><!-- /.eight-col -->
41 by Graham Bancroft
Move events to the bottom of the page. Change latest news to show latest everything.
140
<?php endif; // if have_posts ends 
141
49 by Graham Bancroft
Impliment new design
142
/* ============== end pull in latest articles ============== */
41 by Graham Bancroft
Move events to the bottom of the page. Change latest news to show latest everything.
143
?>
144
145
<?php
146
/* ============== pull in most viewed articles ============== */
147
  wp_reset_query();
148
	$paged = (get_query_var('paged')) ? get_query_var('paged') : 1; // Needed for pagination
149
	$query = new WP_Query( array(
54 by Graham Bancroft
Phase 2 updates
150
	  'posts_per_page'  => 2,
151
    'topic'           => $current_tax,
152
    'post_type'       => 'post',
153
    'post__not_in'    => $do_not_duplicate,
154
    'meta_key'        => 'post_views_count',
155
    'orderby'         => 'meta_value_num',
156
    'paged'           => $paged
41 by Graham Bancroft
Move events to the bottom of the page. Change latest news to show latest everything.
157
	));
158
?>
159
160
<?php if ($query->have_posts()) : ?>
49 by Graham Bancroft
Impliment new design
161
<div class="box box-highlight  eight-col">
162
	<h2>Most viewed in <span><?php echo strtolower(wp_title( '', false, 'right' )); ?></span></h2>
163
	<ul class="no-bullets">
164
	<?php 
165
		while( $query->have_posts() ): 
166
		$query->the_post(); 
167
		$do_not_duplicate[] = $post->ID ?>
168
        <li class="eight-col"><?php get_template_part("content_home"); ?>	</li>
169
	<?php endwhile; ?>
170
	</ul>
171
</div><!-- /.box -->
41 by Graham Bancroft
Move events to the bottom of the page. Change latest news to show latest everything.
172
<?php endif; // if have_posts ends 
173
/* ============== end pull in most viewed articles ============== */
174
?>
175
54 by Graham Bancroft
Phase 2 updates
176
<?php /* ============== pull in latest events ============== */
177
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1; // Needed for pagination
178
$exclude_cat = 'downloads';
179
$category = get_category_by_slug($exclude_cat);
180
$query = new WP_Query( array(
181
	'topic'           => $current_tax,
182
  'order'           => 'ASC',
183
  'orderby'         => 'date',
184
  'paged'           => $paged,
185
  'post__not_in'    => $do_not_duplicate,
186
  'post_type'       => 'event',
187
  'meta_key'        => '_end_eventtimestamp',
188
  'meta_value'      => $current_timestamp,
189
	'orderby'         => 'meta_value',
190
  'posts_per_page'  => 9999,
191
  'meta_compare'    => '>'
192
));
193
?><?php if ( $query->have_posts() ) : ?>
194
195
<div class="eight-col box box-highlight no-margin-bottom">
196
    <h2>Upcoming events</h2>
197
    <ul class="no-bullets">
198
        <?php
199
            while( $query->have_posts() ):
200
            $query->the_post();
201
            $do_not_duplicate[] = $post->ID ;
202
                // get time gubbin's
203
                $current_time = current_time('mysql'); 
204
                list( $today_year, $today_month, $today_day, $hour, $minute, $second ) = split( '([^0-9])', $current_time );
205
                $end_month = get_post_meta( $post->ID, '_end_month', true );
206
                $end_day = get_post_meta( $post->ID, '_end_day', true );
207
                $end_year = get_post_meta( $post->ID, '_end_year', true );
208
                $eventend = $end_year . $end_month . $end_day;
209
                $current_timestamp = $today_year . $today_month . $today_day;
210
            ?>
211
            <?php if($eventend >= $current_timestamp) : ?>
212
        <li><?php get_template_part("/includes/_event_meta"); ?></li><?php endif; ?><?php endwhile; ?>
213
    </ul>
214
</div><!-- /.eight-col -->
215
<?php endif; // if have_posts ends
216
 wp_reset_query();
217
/* ============== end pull in latest events ============== */ ?>
218
</div><!-- /.eight-col -->
219
220
<aside id="sidebar" class="four-col last-col">
41 by Graham Bancroft
Move events to the bottom of the page. Change latest news to show latest everything.
221
<?php
54 by Graham Bancroft
Phase 2 updates
222
$myTopics = array("phone","tablet","internet-of-things");
223
if( !$current_tax == $myTopics ) :
224
/* ============== pull in topic specific cta ============== */
14.1.1 by Graham Bancroft
Mobile beta
225
  wp_reset_query();
226
	$paged = (get_query_var('paged')) ? get_query_var('paged') : 1; // Needed for pagination
227
	$query = new WP_Query( array(
54 by Graham Bancroft
Phase 2 updates
228
	  'posts_per_page'  => 2,
229
    'topic'           => $current_tax,
230
    'post_type'       => 'topiccta',
231
    'post__not_in'    => $do_not_duplicate,
232
    'paged'           => $paged
14.1.1 by Graham Bancroft
Mobile beta
233
	));
234
?>
235
<?php if ($query->have_posts()) : ?>
54 by Graham Bancroft
Phase 2 updates
236
		<?php 
237
			while( $query->have_posts() ): 
238
			$query->the_post(); 
239
			$do_not_duplicate[] = $post->ID;
240
			$slug = basename(get_permalink()); ?>					
241
	<div class="box box-highlight box-<?php echo strtolower(wp_title( '', false, 'right' )); ?> box-<?php echo $slug; ?> contextual-footer four-col">
242
        <h2><?php the_title(); ?></h2>
243
        <?php the_content(); ?>
244
	</div><!-- /.box -->
245
		<?php endwhile; ?>
14.1.1 by Graham Bancroft
Mobile beta
246
<?php endif; // if have_posts ends 
54 by Graham Bancroft
Phase 2 updates
247
wp_reset_query(); 
248
/* ============== end pull in topic specific cta ============== */ 
249
endif; ?>
14.1.1 by Graham Bancroft
Mobile beta
250
58 by Graham Bancroft
Add digest to all pages
251
<?php get_template_part("includes/_digest"); ?>
252
54 by Graham Bancroft
Phase 2 updates
253
    <div class="box box-highlight four-col">
49 by Graham Bancroft
Impliment new design
254
    	<h2>All <?php echo strtolower(wp_title( '', false, 'right' )); ?> resources</h2>
255
    	<ul class="no-bullets no-margin-bottom">
256
    	<?php
257
    		// get all the categories from the database
258
    		$cats = get_categories(); 
259
    		// loop through the categries
260
    			foreach ($cats as $cat) :
261
    				// setup the cateogory ID
262
    				$cat_id= $cat->term_id;
263
    				// create a custom wordpress query
264
    				query_posts("topic=$current_tax&cat=$cat_id&posts_per_page=1");
265
    				// start the wordpress loop!
266
    		      if (have_posts()) : while (have_posts()) : the_post(); 
267
    						echo "<li><a href='/topic/" . $current_tax . "?cat=".$cat_id."'>".$cat->name." (" .$wp_query->found_posts . ")</a></li>";
268
    		      ?>
269
    					<?php endwhile; endif; // done our wordpress loop. Will start again for each category ?>
270
    			<?php endforeach; // done the foreach statement ?>
271
    	</ul>
272
    </div><!-- /.box -->
14.1.1 by Graham Bancroft
Mobile beta
273
<?php /* ============== end links to all topics ============== */ ?>
49 by Graham Bancroft
Impliment new design
274
</aside>
275
276
</div><!-- /.inner-wrapper -->
277
</div><!-- /.row -->
14.1.1 by Graham Bancroft
Mobile beta
278
<?php get_footer(); ?>