Skip to content

Instantly share code, notes, and snippets.

@TwP
Created February 23, 2009 15:45
Show Gist options
  • Save TwP/69012 to your computer and use it in GitHub Desktop.
Save TwP/69012 to your computer and use it in GitHub Desktop.
module PortfolioHelper
def portfolio_prev_next
items = @pages.find(:all,
:in_directory => "/portfolio",
:sort_by => "title")
portfolio = @pages.find(:title => "Portfolio")
current = @pages.find(:title => @page.title,
:in_directory => "/portfolio")
index = items.index(current)
prev_page = items.first == current ? portfolio : items[index-1]
next_page = items.last == current ? portfolio : items[index+1]
html = <<-HTML
<a href="..#{prev_page.url}" id="back">
&larr; #{h(prev_page.title)}
</a>
<a href="..#{next_page.url}" id="forward">
#{h(next_page.title)} &rarr;
</a>
HTML
return html
end
end
Webby::Helpers.register(PortfolioHelper)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment