Merge lp:~nuthinking/blahblahblah/toolkit-fix into lp:~blah-devs/blahblahblah/release

Proposed by Christian Giordano
Status: Merged
Merge reported by: Christian Giordano
Merged at revision: not available
Proposed branch: lp:~nuthinking/blahblahblah/toolkit-fix
Merge into: lp:~blah-devs/blahblahblah/release
Diff against target: 140 lines (+33/-92)
1 file modified
toolkit.php (+33/-92)
To merge this branch: bzr merge lp:~nuthinking/blahblahblah/toolkit-fix
Reviewer Review Type Date Requested Status
Design Blog developers Pending
Review via email: mp+87800@code.launchpad.net

Description of the change

Refactored the toolkit page, now if a section doesn't have pages associated it won't show up (and it will be easier to add new sections).

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'toolkit.php'
2--- toolkit.php 2010-09-01 13:39:38 +0000
3+++ toolkit.php 2012-01-06 19:16:03 +0000
4@@ -4,104 +4,45 @@
5 */
6 ?>
7 <?php get_header(); ?>
8+<?php
9+ $sections = array('Brand Resources','Desktop','Unity');
10+
11+ function generateKey($name){
12+ $key = strtolower($name);
13+ return str_replace(' ','_',$key);
14+ }
15+?>
16 <div id="leftColumn">
17 <div class="titleBox">
18 <h1 class="tplToolkit">
19 The toolkit
20 </h1>
21 </div>
22- <!--div id="toolkitPickerHeader">
23- <a href="#" id="pickerTab">
24- Hide me
25- </a>
26- <div class="clearBoth"></div>
27- </div>
28- <div id="toolkitPicker">
29- <div id="byRelease">
30- <h4>View toolkit by release</h4>
31- <ul>
32- <li><a href="#">Wanking Walrus</a></li>
33- <li><a href="#">Mindful Midget</a></li>
34- </ul>
35- </div>
36- <div id="byFunction">
37- <h4>Customise your view</h4>
38- <ul>
39- <li><input type="checkbox" id="test1" name="test1" /><label for="test1">test1</label></li>
40- <li><input type="checkbox" id="test1" name="test1" /><label for="test1">test1</label></li>
41- <li><input type="checkbox" id="test1" name="test1" /><label for="test1">test1</label></li>
42- <li><input type="checkbox" id="test1" name="test1" /><label for="test1">test1</label></li>
43- <li><input type="checkbox" id="test1" name="test1" /><label for="test1">test1</label></li>
44- <li><input type="checkbox" id="test1" name="test1" /><label for="test1">test1</label></li>
45- <li><input type="checkbox" id="test1" name="test1" /><label for="test1">test1</label></li>
46- <li><input type="checkbox" id="test1" name="test1" /><label for="test1">test1</label></li>
47- <li><input type="checkbox" id="test1" name="test1" /><label for="test1">test1</label></li>
48- <li><input type="checkbox" id="test1" name="test1" /><label for="test1">test1</label></li>
49- <li class="clearBoth"></li>
50- </ul>
51- </div>
52- <div class="clearBoth"></div>
53- </div-->
54- <div class="toolkitCat">
55- <h2 class="toolkitHeader">
56- <img src="<?php bloginfo('template_directory')?>/images/arrow_open.png" alt="toggle"/>
57- Brand Resources
58- </h2>
59- <div class="toolkitContainer">
60- <?php
61- $tk_page_counter=0;
62- foreach(get_pages(array('child_of'=>get_ID_by_page_name('The toolkit'),'meta_key'=>'toolkit','meta_value'=>'brand_resources','sort_order'=>'asc','sort_column'=>'menu_order')) as $tk_page): ?>
63- <div class="toolkitBox<?php if($tk_page_counter++%3==0)echo' firstToolkitBox'; ?>">
64- <a href="<?php echo get_permalink_or_redirect($tk_page->ID);?>" class="toolkitImgLink">
65- <?php if(has_post_thumbnail($tk_page->ID))echo get_the_post_thumbnail($tk_page->ID); ?>
66- </a>
67- <a href="<?php echo get_permalink_or_redirect($tk_page->ID);?>"><?php echo $tk_page->post_title; ?></a>
68- <?php echo $tk_page->post_excerpt; ?>
69- </div>
70- <?php endforeach; ?>
71- <div class="clearBoth"></div>
72- </div>
73- </div>
74- <div class="toolkitCat">
75- <h2 class="toolkitHeader">
76- <img src="<?php bloginfo('template_directory')?>/images/arrow_open.png" alt="toggle"/>
77- Desktop
78- </h2>
79- <div class="toolkitContainer">
80- <?php
81- $tk_page_counter=0;
82- foreach(get_pages(array('child_of'=>get_ID_by_page_name('The toolkit'),'meta_key'=>'toolkit','meta_value'=>'desktop','sort_order'=>'asc','sort_column'=>'menu_order')) as $tk_page): ?>
83- <div class="toolkitBox<?php if($tk_page_counter++%3==0)echo' firstToolkitBox'; ?>">
84- <a href="<?php echo get_permalink_or_redirect($tk_page->ID);?>" class="toolkitImgLink">
85- <?php if(has_post_thumbnail($tk_page->ID))echo get_the_post_thumbnail($tk_page->ID); ?>
86- </a>
87- <a href="<?php echo get_permalink_or_redirect($tk_page->ID);?>"><?php echo $tk_page->post_title; ?></a>
88- <?php echo $tk_page->post_excerpt; ?>
89- </div>
90- <?php endforeach; ?>
91- <div class="clearBoth"></div>
92- </div>
93- </div>
94- <div class="toolkitCat">
95- <h2 class="toolkitHeader">
96- <img src="<?php bloginfo('template_directory')?>/images/arrow_open.png" alt="toggle"/>
97- Unity
98- </h2>
99- <div class="toolkitContainer">
100- <?php
101- $tk_page_counter=0;
102- foreach(get_pages(array('child_of'=>get_ID_by_page_name('The toolkit'),'meta_key'=>'toolkit','meta_value'=>'unity','sort_order'=>'asc','sort_column'=>'menu_order')) as $tk_page): ?>
103- <div class="toolkitBox<?php if($tk_page_counter++%3==0)echo' firstToolkitBox'; ?>">
104- <a href="<?php echo get_permalink_or_redirect($tk_page->ID);?>" class="toolkitImgLink">
105- <?php if(has_post_thumbnail($tk_page->ID))echo get_the_post_thumbnail($tk_page->ID); ?>
106- </a>
107- <a href="<?php echo get_permalink_or_redirect($tk_page->ID);?>"><?php echo $tk_page->post_title; ?></a>
108- <?php echo $tk_page->post_excerpt; ?>
109- </div>
110- <?php endforeach; ?>
111- <div class="clearBoth"></div>
112- </div>
113- </div>
114+ <?php foreach($sections as $s): ?>
115+ <?php $key = generateKey($s);
116+ $pages = get_pages(array('child_of'=>get_ID_by_page_name('The toolkit'),'meta_key'=>'toolkit','meta_value'=>$key,'sort_order'=>'asc','sort_column'=>'menu_order'));
117+ if(count($pages)>0): ?>
118+ <div class="toolkitCat">
119+ <h2 class="toolkitHeader">
120+ <img src="<?php bloginfo('template_directory')?>/images/arrow_open.png" alt="toggle"/>
121+ <?php echo $s ?>
122+ </h2>
123+ <div class="toolkitContainer">
124+ <?php
125+ foreach($pages as $tk_page): ?>
126+ <div class="toolkitBox<?php if($tk_page_counter++%3==0)echo' firstToolkitBox'; ?>">
127+ <a href="<?php echo get_permalink_or_redirect($tk_page->ID);?>" class="toolkitImgLink">
128+ <?php if(has_post_thumbnail($tk_page->ID))echo get_the_post_thumbnail($tk_page->ID); ?>
129+ </a>
130+ <a href="<?php echo get_permalink_or_redirect($tk_page->ID);?>"><?php echo $tk_page->post_title; ?></a>
131+ <?php echo $tk_page->post_excerpt; ?>
132+ </div>
133+ <?php endforeach; ?>
134+ <div class="clearBoth"></div>
135+ </div>
136+ </div>
137+ <?php endif; ?>
138+ <?php endforeach; ?>
139 </div>
140 <?php get_sidebar(); ?>
141

Subscribers

People subscribed via source and target branches