Created
February 23, 2009 15:45
-
-
Save TwP/69012 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"> | |
← #{h(prev_page.title)} | |
</a> | |
<a href="..#{next_page.url}" id="forward"> | |
#{h(next_page.title)} → | |
</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