Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
archive mod to skip months without posts
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
M Graff  
View profile  
 More options Oct 19, 7:08 pm
From: M Graff <skan.gryp...@gmail.com>
Date: Mon, 19 Oct 2009 16:08:29 -0700 (PDT)
Local: Mon, Oct 19 2009 7:08 pm
Subject: archive mod to skip months without posts
I've added a new feature others might be interested in using.

I tend to be very hit-or-miss when I post to my blog.  Unfortunately,
this means some months actually go by without a single post.  Even
many months in a row.

Rather than see:
  March 2008 (0)
  Feburary 2008 (0)
   January 2008 (0)

I wanted to just omit these.  I found no real way to do this in
liquid, but I'm a liquid novice.  Make that newbie.

So, rather than using
  {% for month in articles.months %}
I can now use
  {% for month in articles.months_with_articles %}

Add this to the end of app/drops/section_drop.rb, right before the
final 'end' line, and you can too:

def months_with_articles
  if @months_with_articles.nil?
    @months_with_articles = []
    @source.articles.find(:all, :order => 'published_at desc', :select
=> 'published_at').each do |article|
      if article.published_at
        this_month = article.published_at.beginning_of_month
        unless @months_with_articles.include?(this_month)
          @months_with_articles << this_month
        end
      end
    end
  end
  @months_with_articles
end


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Vahagn Hayrapetyan  
View profile  
 More options Oct 20, 3:44 pm
From: Vahagn Hayrapetyan <vaha...@gmail.com>
Date: Tue, 20 Oct 2009 21:44:05 +0200
Local: Tues, Oct 20 2009 3:44 pm
Subject: Re: [Mephisto] archive mod to skip months without posts

Cool trick, thanks for sharing.

/ Vahagn


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google