[Petal] Reengineering of HTML::Pager

Jean-Michel Hiver jhiver@mkdoc.com
Wed, 16 Oct 2002 12:18:42 +0100


> Hi all,
> 
> I use a module called CGI::Application to develop my Perl web apps. If my 
> memory serves me correctly, HTML::Template and HTML::Pager were born out 
> of Sam Tregar's work with CGI::Application. I was using HTML::Template in 
> a project until I came across Petal. Now that I am reimplementing the 
> templates in Petal, I have found that in one case I was using HTML::Pager 
> to page database search results to the users. H:P os heavily tied into 
> HTML::Template. This situation wouldn't do for me long-term, so I have 
> reworked HTML::Pager to support Petal templates.

Hi William,

This is great! I have not thought about writing a pager module because
basically I didn't think the task was hard enough to be abstracted /
modularized, but if you feel like writing a Petal::Pager module you
should go for it :)

Mind you it is hard to write a very generic pager I think. For instance
I'm doing paging for our new discussion forum, but the paging is also
combined with message threading, which spices things up a little bit.

Here are the relevant Petal bits which I'm using:


# template discussion/list/thread.en.html
# ---------------------------------------
    <ul petal:if="children">
      <li petal:repeat="message children">
        <a href="$message/uri"
           petal:attributes="name string:id-${message/uid};
                             id string:id-${message/uid}">$message/subject</a>
        <em>$message/name</em>
        <span petal:define="children message/children">
          <?petal:include file="/discussion/list/thread.en.html"?>
        </span>
      </li>
    </ul>


# template discussion/list/navigation-bar.en.html 
# -----------------------------------------------
    <p petal:if="here/has_many_slices">
      <span petal:repeat="slice here/slices">
        <a
           petal:if="false:slice/current"
           petal:attributes="href here/uri --page slice/number"
           petal:content="slice/number">1</a>
        <strong
           petal:if="true:slice/current">$slice/number</strong>
        <span
           petal:replace="string:|"
           petal:if="false:__is_last__" />
      </span>
    </p>


> The work was relatively easy and the benefits of having a Petalized 
> version of HTML::Pager were worth the effort. However, now that I've 
> completed it, I'm wondering if there was perhaps a better solution that 
> others are using to page through database results using Petal. Is your 
> solution as featureful as HTML::Pager? Would anybody be interested in a 
> copy of this hacked module?

Well, it would be certainly interesting to take a look at it :)

Happy Hacking,
-- 
IT'S TIME FOR A DIFFERENT KIND OF WEB
================================================================
  Jean-Michel Hiver - Software Director
  jhiver@mkdoc.com
  +44 (0)114 255 8097
================================================================
                                      VISIT HTTP://WWW.MKDOC.COM