Mephisto article list pagination plugin

posted: March 28th, 2007 · by: Sven

in: Programming · tagged as: , , , , , ·  11 comments »

When I switched to Mephisto last month I could not believe my eyes that there’s no post pagination on any of the section pages that list blog posts besides the archives.

Since, I wondered if that’s probably just a bit too closeminded to consider this a usability breakdown or something like this … might just be a matter of taste, too. But then I happened to run in this very issue twice the other day.

I consider this functionality crucial because it’s a well-known usability pattern all across the web these days. Millions of blogging engines do it this way (don’t they?), so it should be default in Mephisto, too, IMO … but actually it isn’t. So I decided to follow Rick’s suggestion and write a plugin to implement this.

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

Searching for advice on how to do this the right way in Ruby on Rails I’ve found a lot of interesting stuff … I just haven’t found anything about how to overwrite an existing applications controller action - something that I considered necessary for that pagination functionality I wanted to realize. If you happen to be able to tell me something about this, please do.

So here’s what I’ve been able to come up with myself.

I hook into the ActionController’s before_filter and overwrite the entire method from there! Uuuuuuuha. Yes, I consider this aproach to be rather brutally hackish and ugly. It actually disturbs me if I look at this! I just don’t know how to do it in a more apropriate way. Is there any?

([Update] I’ve found a less hackish way to overwrite the Controller in the meantime. I’ll put some notes together about some useful plugin dev techniques that I’ve collected.)

Here’s the code:

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

[Update] I’ve added some notes on how to use this plugin.

Leave a comment

11 Comments

  1. Scott said March 30th, 2007 at 05:59 PM  

    Any instructions on how to actually use the plugin? Are there any special liquid tags involved? Or is it just a matter of dropping it into a Mephisto install and it magically works?

  2. Sven said March 31st, 2007 at 12:16 AM  

    Whoops. Yes, sorry.

    I definitely should have described that. I’m away on holidays for some days but I’ll hand that in asap. As a quick shot, here’s a snippet copied from my themes/site-1/[theme-name]/templates/_shared.liquid

    
    {% if pages %}
        <p id="pagination">
            {{ section | prev_next_section_page_links: pages }}
        </p>
    {% endif %}
    

    This adds the pagination that you see (e.g.) on the blog homepage (http://www.artweb-design.de).

    HTH!

  3. Scott said March 31st, 2007 at 04:53 PM  

    Thanks Sven, much appreciated. I see mention of some form of pagination code in the changelog in Mephisto, but haven’t had any luck in getting it working. Hope to be able to use your plugin, at least in the meantime.

  4. Sven said April 3rd, 2007 at 01:34 AM  

    Scott,

    in case that you don’t have subscribe to my blog but the comments feed of this article: I’ve just added some notes on how to use this plugin

  5. Will Duncan said June 21st, 2007 at 01:27 PM  

    Since I came across this page first and did not have success with the code you posted in your comment, it rendered out a # instead of the older/newer post links. I’ll point out that this works in the _shared.liquid file

    {% if pages %}
        <p id="pagination">
            {{ section | prev_next_section_page_links: pages }}
        </p>
    {% endif %}

    Only difference is “page instead of pages…and since I am a lazy copy/paste freak I didn’t pick it up right away.

  6. Sven said June 26th, 2007 at 01:42 PM  

    Will, thanks for pointing that out! Year, I’ll correct that in my own comment (and when I’m at it I’ll add pre tags to your comment so that Markdown doesn’t screw your underscores … I’m getting to think that this behaviour is a major annoyance in Markdown actually).

  7. jack said January 23rd, 2011 at 11:41 AM  

    thanks for that heads up. That’s a useful tip! I’ve never ran into that, but for sure that’s something quite some people will need a solution for. cheap vps

  8. chat said March 31st, 2011 at 07:52 PM  

    This fixed my pagination =

    The following cleaned up the issue:

    Dependencies.loadoncepaths -= Dependencies.loadoncepaths.select{|path| \ path =~ %r(^#{File.dirname(FILE)}) }

  9. Okey Oyunu said May 12th, 2011 at 04:07 PM  

    Thanks for this article. Tüm dünya artik okey oyunu oynuyor. Yillardir bir çok oyun programi olmasina ragmen, içlerinden en güzeli olarak nitelendirebilecegimiz tek bir site göze çarpmaktadir. Diger tüm okey oyunu programlarinin aksine ücretsiz olmasi ve 3 boyutlu olarak hizmet vermesi mükemmel bir gelismedir. Sizlerde www.okey-oyunu.com adresinden bu essiz okey oyununu indirebilirsiniz. Kullanimi çok basit ve Türkçe dil seçenegi ile kolaylikla oyuna baslayabilirsiniz. Ister kendi ülkenizden, isterseniz dünyanin tüm farkli bölgelerinden dilediginiz oyun odalarini seçerek, oyuna hemen baslayabilirsiniz. Okey oyunu oynamak için artik arkadas bile aramaniza gerek kalmadan, bilgisayarinizdan 100 binlerce üye ile online olarak okey oyununu oynamanin zevkine varabilirsiniz.

  10. porno said May 22nd, 2011 at 01:31 PM  

    I do agree with all of the ideas you have presented in your post. They’re really convincing and will definitely work. Still, the posts are too short for newbies. Could you please extend them a bit from next time? Thanks for the post.

  11. porno said May 22nd, 2011 at 02:03 PM  

    good comment. thanks you friends.

    I’ve surfed the net more than three hours today, however, I haven’t found such useful information. Thanks a lot, it is really useful to me

Sorry, comments are closed for this article.

artweb design
Sven Fuchs
Grünberger Str. 65
10245 Berlin, Germany


http://www.artweb-design.de

Fon +49 (30) 47 98 69 96
Fax +49 (30) 47 98 69 97