Changing protocol or urls in will_paginate

C

Costa Nicolaou

Hey,

I've been looking to override the default protocol provided with
will_paginate.

Is there a chance anyone knows how to do that?

I tried doing so using this helper but it never works since url_for is
accepting a string (page)

-------------------------------

class PaginationListLinkRenderer < WillPaginate::LinkRenderer

def to_html
links = @options[:page_links] ? windowed_links : []

links.unshift(page_link_or_span(@collection.previous_page,
'previous', @options[:previous_label]))
links.push(page_link_or_span(@collection.next_page, 'next',
@options[:next_label]))

html = links.join(@options[:separator])
@options[:container] ? @template.content_tag:)div, html,
html_attributes) : html
end

protected

def windowed_links
visible_page_numbers.map { |n| page_link_or_span(n, (n ==
current_page ? 'current' : nil)) }
end

def page_link_or_span(page, span_class, text = nil)
text ||= page.to_s
if page && page != current_page
page_link(page, text, :class => span_class)
else
page_span(page, text, :class => span_class)
end
end

def page_link(page, text, attributes = {})
@template.content_tag:)span, @template.link_to(text, url_for(page)),
attributes)
end

def page_span(page, text, attributes = {})
@template.content_tag:)span, text, attributes)
end

end
 
B

Brian Candler

Please post questions about Rails to a Rails forum.

This list is for Ruby, the programming language. Rails is a big
application which just happens to be written *in* Ruby. Many (perhaps
most) of the people on this list don't have any interest in Rails.
 
C

Costa Nicolaou

Brian said:
Please post questions about Rails to a Rails forum.

This list is for Ruby, the programming language. Rails is a big
application which just happens to be written *in* Ruby. Many (perhaps
most) of the people on this list don't have any interest in Rails.

Hey Brian,

Yep true, will move that to another list.

But i just thought that will_paginate is also used outside the Rails
world and is written in Ruby, as you probably know.
 
D

Diego Viola

[Note: parts of this message were removed to make it a legal post.]

Please ask in a Rails forum.
 

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

No members online now.

Forum statistics

Threads
474,145
Messages
2,570,826
Members
47,371
Latest member
Brkaa

Latest Threads

Top