Fork me on GitHub

pager with pnRender  Bottom

  • Postnukers,

    I have been trying to figure out how to use the pager for pnRender and just can't figure it out. I did look through the documentation and the forum and really didn't see anything. Can someone point me to a resource or explain how to use the pager? Here are some specifics....

    I have a search function for my book module. I want to include a pager if the results get over about 20. So, when the search is done I have an array containing the data for article urls ($art_urls). I am using a pnRender object to display the results...

    Code

    $pnRender = new pnRender('Book');
    $pnRender->assign('art_urls', $art_urls);
    return $pnRender->fetch('book_user_search.htm');


    And the template is very simple...

    Code

    <!--[*  $Id: book_admin_main.htm,v 1.2 2006/11/30 19:29:32 paustian exp $  *]-->
    <!--[section name=i loop=$art_urls]-->
    <!--[$art_urls[i]]--><br />
    <!--[/section]-->


    What I would like to do is add a pager and I cannot figure out how to do it. Any help is appreciated.

    BTW. I will be releasing a much improved book module in the next few weeks. For a sneak peek at the kinds of things it can do, go to http://www.microbiologytext.com/

    Tim
  • In your PHP file add this code....

    Code

    $pnRender->assign('pager', array('numitems' => {...total number of item...},
                                     'itemsperpage' => {...number of items displayed...}));


    Then in your template add this where you want the pager to show....

    Code

    <!--[pager show=page rowcount=$pager.numitems limit=$pager.itemsperpage txt_first=$L_MORE posvar=startnum shift=1]-->


    --
    cyber_wolf
    www.bkbsolutions.com - My Zikula module development site.
  • cyber_wolf,

    Thanks a bunch, that worked. So here is a summary of what I did. $art_urls is just an array of URLs

    Code

    $pnRender = new pnRender('Book');
    $pnRender->assign('art_urls', $art_urls);
    $pnRender->assign('pager', array('numitems' => $total,
                                     'itemsperpage' => 25));
    return $pnRender->fetch('book_user_search.htm');


    Then here is the working htm code in the book_user_search.htm file

    Code

    <!--[section name=i loop=$art_urls max=$pager.itemsperpage]-->
    <!--[$art_urls[i]]--><br />
    <!--[/section]-->

    <!--[pager show=page rowcount=$pager.numitems limit=$pager.itemsperpage txt_first=$L_MORE posvar=startnum shift=1]-->


    Note the limit on the section. This is critical to get it to only list the lines that the pager is pointing to. One other question, what does $L_MORE stand for. I could find no reference to it.
  • I don't know. I saw it in an example and hasn't caused me any problems. Probably since $L_MORE was never defined. Looks like that parameter can be removed.

    --
    cyber_wolf
    www.bkbsolutions.com - My Zikula module development site.

This list is based on users active over the last 60 minutes.