FAQ
Hi, there, Oliver and everyone:)

Thanks for your posting:)
Referring to
http://www.mail-archive.com/catalyst@lists.scsys.co.uk/msg05232.html, I
adopted the code given into my template and it looks really good but the
hyperlink doesn't have any value. I suppose it's because [%
c.req.uri_with(...) %] is not defined.

1)why is the Catalyst request variable being used instead of the
Catalyst object?
2)how can we get the Catalyst request working properly (ie to be defined)?


thank you :)

K . akimoto




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

Oliver Charles
Thu, 22 Jan 2009 07:50:17 -0800

I might as well join in with this :) Here's what we use at work:

[% IF pager %]
<ul class="paginator">
<li class="counter">Page [% pager.current_page %] of [%
pager.last_page %]</li>
<li><a href="[% c.req.uri_with( page => pager.first_page )
%]">&laquo;</a></li>
[% IF pager.previous_page %]
<li><a href="[% c.req.uri_with( page =>
pager.previous_page ) %]">&lt;</a></li>
[% END %]

[% start = (pager.current_page - 3) > 0 ? (pager.current_page -
3) : 1;
FOREACH page IN [ start .. pager.last_page ] %]
[% LAST IF loop.count > 6 %]
<li[% IF pager.current_page == page; ' class="current"'; END %]>
<a href="[% c.req.uri_with( page => page ) %]">[% page
%]</a>
</li>
[% END %]

[% IF pager.next_page %]
<li><a href="[% c.req.uri_with( page => pager.next_page )
%]">&gt;</a></li>
[% END %]
<li><a href="[% c.req.uri_with( page => pager.last_page )
%]">&raquo;</a></li>
</ul>
[% END %]

Though my colleague rightly suggested we subclass Data::Page and
perform the sliding window in there. This shows first page, previous
page, the current page surrounded by near-by pages. Seems to do the
job so far!

Search Discussions

  • K. Akimoto at Jun 21, 2009 at 5:16 am
    Hi, all,

    Looked at J. Rockway's Catalyst book (page 69) and although there were
    some typo errors( ie. c.req was represented as c.res in the final
    paragraph ), I got it working in that I just had to make the parameters
    to c.req.uri_with as hash references instead of just hashes.

    Thanks

    K. akimoto


    On Sun, Jun 21st, 2009 at 2:37 PM, kakimoto@tpg.com.au wrote:

    Hi, there, Oliver and everyone:)

    Thanks for your posting:)
    Referring to
    http://www.mail-archive.com/catalyst@lists.scsys.co.uk/msg05232.html,
    I
    adopted the code given into my template and it looks really good but
    the
    hyperlink doesn't have any value. I suppose it's because [%
    c.req.uri_with(...) %] is not defined.

    1)why is the Catalyst request variable being used instead of the
    Catalyst object?
    2)how can we get the Catalyst request working properly (ie to be
    defined)?


    thank you :)

    K . akimoto




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

    Oliver Charles
    Thu, 22 Jan 2009 07:50:17 -0800

    I might as well join in with this :) Here's what we use at work:

    [% IF pager %]
    <ul class="paginator">
    <li class="counter">Page [% pager.current_page %] of [%
    pager.last_page %]</li>
    <li><a href="[% c.req.uri_with( page => pager.first_page )
    %]">&laquo;</a></li>
    [% IF pager.previous_page %]
    <li><a href="[% c.req.uri_with( page =>
    pager.previous_page ) %]">&lt;</a></li>
    [% END %]

    [% start = (pager.current_page - 3) > 0 ? (pager.current_page
    -
    3) : 1;
    FOREACH page IN [ start .. pager.last_page ] %]
    [% LAST IF loop.count > 6 %]
    <li[% IF pager.current_page == page; ' class="current"';
    END %]>
    <a href="[% c.req.uri_with( page => page ) %]">[%
    page
    %]</a>
    </li>
    [% END %]

    [% IF pager.next_page %]
    <li><a href="[% c.req.uri_with( page => pager.next_page
    )
    %]">&gt;</a></li>
    [% END %]
    <li><a href="[% c.req.uri_with( page => pager.last_page )
    %]">&raquo;</a></li>
    </ul>
    [% END %]

    Though my colleague rightly suggested we subclass Data::Page and
    perform the sliding window in there. This shows first page, previous
    page, the current page surrounded by near-by pages. Seems to do the
    job so far!


    _______________________________________________
    List: Catalyst@lists.scsys.co.uk
    Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
    Searchable archive:
    http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
    Dev site: http://dev.catalyst.perl.org/

  • Fernan Aguero at Jun 21, 2009 at 2:18 pm

    On Sun, Jun 21, 2009 at 1:37 AM, wrote:
    Hi, there, Oliver and everyone:)

    ?Thanks for your posting:)
    ?Referring to
    http://www.mail-archive.com/catalyst@lists.scsys.co.uk/msg05232.html, I
    adopted the code given into my template and it looks really good but the
    hyperlink doesn't have any value. I suppose it's because [%
    c.req.uri_with(...) %] is not defined.

    1)why is the Catalyst request variable being used instead of the
    Catalyst object?
    K,

    this may change depending on your configuration of the TT view. In my
    case it's not 'c' but 'Catalyst', as in

    [% Catalyst.req.uri_with() -%]
    2)how can we get the Catalyst request working properly (ie to be defined)?
    You should look into your lib/yourapp/View/TT.pm file for
    CATALYST_VAR. This sets the name of the variable that contains the
    catalyst context object in your templates. This is what mine looks
    like:

    package portfolio::View::TT;

    use strict;
    use base 'Catalyst::View::TT';

    __PACKAGE__->config({
    CATALYST_VAR => 'Catalyst',
    INCLUDE_PATH => [
    portfolio->path_to( 'root', 'src' ),
    portfolio->path_to( 'root', 'lib' )
    ],
    PRE_PROCESS => 'config/main',
    WRAPPER => 'site/wrapper',
    ERROR => 'error.tt2',
    TIMER => 0,
    DEBUG => 'vars',
    });

    thank you :)

    ?K . akimoto
    HTH. Cheers,

    --
    fernan
  • K. Akimoto at Jun 21, 2009 at 10:53 pm
    helllo, there, Fernan and everyone :)

    good morning!

    this may change depending on your configuration of the TT view. In
    my
    case it's not 'c' but 'Catalyst', as in

    [% Catalyst.req.uri_with() -%]
    yes, i know that we can either use [% c %] or [% Catalyst %]. My actual
    question is that why are we using the request object in the view ?
    Anyway , sorted it out.
    All good. thank you:)

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcatalyst @
categoriescatalyst, perl
postedJun 21, '09 at 4:37a
activeJun 21, '09 at 10:53p
posts4
users2
websitecatalystframework.org
irc#catalyst

2 users in discussion

K. Akimoto: 3 posts Fernan Aguero: 1 post

People

Translate

site design / logo © 2022 Grokbase