Boyinks4Adventure - Blog Archives

Blog archives are typically pretty straightforward affairs - but in this case I was using a WooTheme for the site that was written for WordPress.  The page has a few features that aren’t straight out of the box with ExpressionEngine, so I wanted to see how hard it would be to replicate them.

 
Download the EE Code for Boyinks4Adventure - Blog Archives

Here is my finished product - you can see that I was able to re-create the main page functionality.  This was mostly straightforward with general-purpose EE tags, with the exception of a couple things. I’ve provided a text version of the template - open that and let’s work through the page:

The Last 30 Posts
This is an easy one - just a weblog:entries loop with a limit of 30.

Categories
EE has a Weblog Categories tag that will return category links for the specified weblog - but what EE doesn’t provide is a native way to get the count of entries in each category.  There are a few ways to do this - like you could write a custom query using the Query Module.  I chose to use a 3rd party plugin called Entries Number by the somewhat mythical Laisvunas (almost 50 addons listed for EE!).  I wrapped {exp:entries_number} tags with {exp:weblog:categories} tags so I could feed entries_number the category_id and get it to return the count.

Monthly Archives
Same story here - EE has a Monthly Archives tag - but it doesn’t return a count.  In this case I did chose to do a custom query that uses the year and month values provided by the native month_links EE tag pair.

So with a quick custom query, a plugin, and some native tags - I was able to replicate the provided design in pretty short order.

Category Navigation

<< Previous Entry   

Next Entry >>

 

Previous Comments

Picture of Ryan Battles

by Ryan Battles

Date: Tuesday, June 22nd, 2010
Comment: #1

I find it funny that EE doesn’t provide a native way to count archives or categories, as it has its roots as a blogging platform.  However, thanks be to the add-on developers or a little custom queries to pull out what you need.  For an EE2 site I am building, I’ve just used Zac Gordon’s Category Count and Low’s Yearly Archives add-ons to get the results I needed.

Mike Boyink

by Mike Boyink (Author)

Date: Tuesday, June 22nd, 2010
Comment: #2

Thanks Ryan - as always there are more than a couple ways to achieve the same ends in EE.

Picture of Ryan Battles

by Ryan Battles

Date: Tuesday, June 22nd, 2010
Comment: #3

No doubt.  Thank you for posting tutorial posts like this so we can learn how to do it at least one way.  I can’t begin to count how many times I’ve googled “How to xxxx in ExpressionEngine” and landed on one of your posts.  They truly are a treasury of information for us all!

Mike Boyink

by Mike Boyink (Author)

Date: Tuesday, June 22nd, 2010
Comment: #4

Information—and affiliate links! :-)

Picture of cjpoki

by cjpoki

Date: Monday, October 4th, 2010
Comment: #5

I am a newbie at EE.. and am trying to add another pic to a slide show on our company website..which was created by a contractor..who used EE V1.6.8 to create the site. How can I add a picture to the template which shows the pics on our home page slide show?

Mike Boyink

by Mike Boyink (Author)

Date: Monday, October 4th, 2010
Comment: #6

It could have been implemented any number of ways - your best bet is to contact the contractor who built it for instructions.

Picture of Walter Pollard

by Walter Pollard

Date: Tuesday, March 22nd, 2011
Comment: #7

I’m having problems linking my monthly archives to the correct post in my blog.

I currently have a template for my blog embedding an archive template.

I’m using weblog categories tag.

I’m confused how to link the monthly post content.

Picture of boyink

by boyink

Date: Tuesday, March 22nd, 2011
Comment: #8

Hey Walter -

The issue is most likely due to using the categories tag.  You need to use the Month Links tag instead.  EE will create the links that will generate the correct URL structure that will cause a template to return month-based results.

Add Your Comment

Commenting is not available in this channel entry.

Unless otherwise stated all content is © Michael Boyink of Train-ee.com & Boyink Interactive. Please don't steal - I've got kids to feed...

dy>