melissa_boyle Posted January 16, 2014 Share Posted January 16, 2014 Hi guys, I have created a basic blog archive using some code from this article which works fine on showing the amount of posts for each month and year: http://processwire.com/talk/topic/263-creating-archives-for-newsblogs-sections/ On clicking on the urls they bring me to a page blog/year/month however shows all blog items as opposed to just those in that year. Does anyone have any ideas? My code can be seen below which posts the month and amount of articles, I need to call the excerpts for each page. The code can be seen below: <?php $channel = $pages->get("/blog/"); $startYear = date("Y"); // this year $endYear = 2009; // or whenever you want it to end $now = time(); for($year = $startYear; $year >= $endYear; $year--) { for($month = 12; $month > 0; $month--) { $startTime = strtotime("$year-$month-01"); // 2011-12-01 example if($startTime > $now) continue; // don't bother with future dates if($month == 12) $endTime = strtotime(($year+1) . "-01-01"); else $endTime = strtotime("$year-" . ($month+1) . "-01"); $entries = $channel->children("created>=$startTime, created<$endTime"); // or substitute your own date field $date = date("F, Y",$startTime); $url = "/blog/" . date("Y",$startTime) . "/" . date("m",$startTime); $count = count($entries); if($count > 0) echo "<p><a class='article-list__link' href='$url'>$date <b>(" . $count . ")</b></a></p>"; // output the month and count } } ?> Any help would be greatly appreciated, Mel Link to comment Share on other sites More sharing options...
kongondo Posted January 16, 2014 Share Posted January 16, 2014 ...no need to double post Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now