← Home

Howto use: Mephisto article list pagination plugin

Update: The following information is most probably outdated. Please refer to the Mephisto Plugin: Paged Article Lists project page.

The plugin adds three new liquid filters for you to use. They all take the current section and pages array as a parameter. Also, you can specify different optional parameters ...

The all-in-one filter

There's a quick all-in-one filter that simply adds one or two links depending on the context (i.e. if there are older posts or not, newer posts or not):

{{ section | prev_next_section_page_links: pages }}	

Use this filter to automatically output contextually "correct" links like the following:

<a class="prev" href="/page/3">&laquo; older posts</a>
<a class="next" href="/">newer posts &raquo;</a>

... you can then use the HTML class attributes to let the links float to the left and right side of the page respectively - like you can see on my blog homepage.

Also, you can define a separator as a third parameter:

{{ section | prev_next_section_page_links: pages, '&middot;' }}

... which will be inserted between the both links, if both are present.

<a class="prev" href="/page/3">&laquo; older posts</a> &middot;
<a class="next" href="/">newer posts &raquo;</a>

More power to the people

These automatic links might not always be what you want. Maybe you need another link text. Or you want to enclose the links in some other tags ...

You might then want to use the following filters that each just generate one link according to the context:

{{ section | link_to_prev_section_page: pages }}	
{{ section | link_to_next_section_page: pages }}	

... which again will get you the same output as above. But this time you can better control the placement of your tags:

<a class="prev" href="/page/3">&laquo; older posts</a>
<a class="next" href="/">newer posts &raquo;</a>

Also, you can now specify the link text as the third parameter:

{{ section | link_to_prev_section_page: pages, "silence is foo!" }}
{{ section | link_to_next_section_page: pages, "where there's foo, there's fire" }}

How to install

You can install this by using Rails' script/plugin installer. Standing in your application's root directory do:

script/plugin install http://svn.artweb-design.de/stuff/mephisto/mephisto_paged_article_list

That should suffice :-)

Don't forget to restart your webserver after messing with your plugins!

blog comments powered by Disqus