
.blog_categories
  %h3=qit "Titre catégories", "Catégories"
  %ul
    -Category.order(:position).each do |category|
      -count = category.articles.recents.joins(:lang_articles).where("lang_articles.enabled = 1 and lang_articles.lang_site_id = ?", @lang.id).count
      -if count > 0
        %li
          =link_to category.lang(I18n.locale.to_s).name+" (#{count})", category_public_article_path(:lang => @lang.slug,:slug => category.lang(I18n.locale.to_s).slug), :title => "Articles de la catégorie \""+category.lang(I18n.locale.to_s).name.to_s+'"'
        
=render :partial => "public/articles/sidebar_socials"

.blog_archives
  %h3 Archives


  %ul
    -first_month = Article.joins(:lang_articles).where("lang_articles.enabled = 1 and lang_articles.lang_site_id = ?", @lang.id).order("articles.published_at").first.published_at.beginning_of_month.beginning_of_day
    -last_month = Article.joins(:lang_articles).where("lang_articles.enabled = 1 and lang_articles.lang_site_id = ?",@lang.id).order("articles.published_at").last.published_at.beginning_of_month.beginning_of_day
    -the_month = last_month

    -while the_month >= first_month
      -articles = Article.joins(:lang_articles).where("lang_articles.enabled = 1 and lang_articles.lang_site_id = ?", @lang.id).where("articles.published_at >= ? and articles.published_at < ?", the_month.beginning_of_month, (the_month+1.month) ).count
    
      -if articles > 0
        %li=link_to l(the_month.to_date, :format => :only_month)+" (#{articles})", archive_public_article_path(:lang => @lang.slug,:year => the_month.year, :month => the_month.month)
    
      -the_month = the_month.prev_month

  




