Hi,
I'm using standard rails pagination (I know it's not perfect but it
suits me humble needs).
I want to add an anchor to the url.
Like making
article/2?page=5
to
article/2?page=5#content
I haven't found an option in the paginator. Can someone help me please?
Thanks very much.
Sorry, but you misunderstood me.
I want that a command like
<%= pagination_links(@slide_pages) %>
appends #content to all URLs it generates.
So that you have
<a href="article/2?page=5#content">
for example.
Just add something like this in your application_helper.rb: (modify the next and previous to add #content.) So in your view you would call <%=pagination(@slide_pages)%>.
def pagination(pages)
rvalue = "<span id=\"pagination\">"
if pages.current.previous
rvalue << link_to('Previous page', { :action => 'list', :page => pages.current.previous})
rvalue << " | " if pages.current.next
end
if pages.current.next
next_page = pages.current.next
page_no = next_page.to_i - 1
rvalue << %(pg. #{page_no} of #{pages.length})
rvalue << " | "
rvalue << link_to('Next page', { :action => 'list', :page => next_page})
end
rvalue << "</span>"
rvalue
end