Plugin if statement not working :(

J

Jordon Bedwell

I'm having a bit of trouble with a Mephisto plugin that doesn't seem to
want to work right. The articles_by_month_and_year won't detect an
empty return at all. For example if they go to /archives/2007/08 and
there are no articles it doesn't return a 404 and if they go to
/archives/200(6|8|9) it doesn't return a 404 either. Can somebody help
me figure out what I'm doing wrong?

module MephistoFullArchives
module MephistoController

def self.included(base)
base.send :alias_method_chain, :dispatch_archives, :full_archives
end

def dispatch_archives_with_full_archives
if params['path'].length < 4
# 3 or Less
# Year and Month + Archives
render_liquid_template_for:)archive, 'section' => @section,
'articles' => articles_by_month_and_year);
else
# Return 404 on Day
# Do people actually want archive links for days?
if params['path'].length == 4
show_404 and return
else
# Anything else might be an archive
# Let Mephisto deal with it.
# On a general basis Mephisto does alright with it.
dispatch_archives_without_full_archives
end
end
end

def articles_by_month_and_year
archives = []
archives = @section.articles.find:)all, :include => :user,
:conditions => ['contents.published_at IS NOT NULL'], :eek:rder =>
'contents.published_at DESC')
if @archives.nil? or @archives.empty?
show_404 and return
else
@articles = archives
end
end

end
end
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top