From ad04e7a4a8d154b90262dbc4464c3494fcb46253 Mon Sep 17 00:00:00 2001 From: Aaron Trevena Date: Thu, 10 Nov 2005 10:09:17 +0000 Subject: [PATCH] improved pager; improved Maypole::View::TT documentation git-svn-id: http://svn.maypole.perl.org/Maypole/trunk@424 48953598-375a-da11-a14b-00016c27c3ee --- Changes | 14 +++++++++----- lib/Maypole/View/TT.pm | 43 +++++++++++++++++++++++++++++++++++++---- templates/factory/pager | 7 +++++-- 3 files changed, 53 insertions(+), 11 deletions(-) diff --git a/Changes b/Changes index b93de7f..8e634cf 100644 --- a/Changes +++ b/Changes @@ -9,11 +9,9 @@ Deprecated: in $r->params, or anything else, is DEPRECATED and likely to break in future releases. Be good, and use proper method calls. -Incompatible API changes: - Maypole: - - is_applicable() renamed to is_model_applicable(), and returns boolean - instead of a status code. Old-style is_applicable() will still work, - but issues a warning. + is_applicable() renamed to is_model_applicable(), and returns boolean + instead of a status code. Old-style is_applicable() will still work, + but issues a warning. API additions and enhancements: Maypole::Application: @@ -31,6 +29,8 @@ API additions and enhancements: - setup() split into setup(), setup_model(), and load_model_subclass() - added new path processing methods for ssl and default table/action - added make_path() and make_uri() + Templates: + - Improved pager macro/include Bug fixes: Fix to cgi_maypole.t (bug 11346) @@ -41,6 +41,8 @@ Bug fixes: @ISA directly, and doesn't inject itself into the chain (bugs 12923 & 14120) Improved Template error reporting (14133) Maypole::Session::generate_unique_id() now returns the id (bug 14124) + Implement -Init flag in Mp::Application (wishlist 14123) + add() alias to push() in Mp::Headers (wishlist 14142) Moved ar accessor to Apache::MVC (bug 14014) Refactored core to support further development in 2.11 and onwards Fixed related_class method (bug 14566) @@ -55,6 +57,8 @@ Documentation: Maypole::Manual::About - added Maypole::Manual::Inheritance - added Maypole::Manual::Terminology + - updated Maypole::Manual::View + - updated Maypole::View:TT diff --git a/lib/Maypole/View/TT.pm b/lib/Maypole/View/TT.pm index 6f9fbc6..8b12deb 100644 --- a/lib/Maypole/View/TT.pm +++ b/lib/Maypole/View/TT.pm @@ -54,7 +54,13 @@ Maypole::View::TT - A Template Toolkit view class for Maypole ..... - [%# Template Toolkit directives and maypole macros go here %] + [% PROCESS macros %] + + [% pager %] + + [% link %] + + [% maybe_link_view %] =head1 DESCRIPTION @@ -249,13 +255,42 @@ L documentation. =head1 MAYPOLE MACROS AND FILTERS -Maypole provides a collection of useful and powerful macros...TO DO +Maypole provides a collection of useful and powerful macros in the templates/factory/macros + and other templates. These can be used in any template with [% PROCESS templatename %]. =head2 link -=head2 other macros +This creates an to a command in the Apache::MVC system by +catenating the base URL, table, command, and any arguments. + +=head2 maybe_link_view + +C takes something returned from the database - either +some ordinary data, or an object in a related class expanded by a +has-a relationship. If it is an object, it constructs a link to the view +command for that object. Otherwise, it just displays the data. + +=head2 pager -=head2 finish this documentation +This is an include template rather than a macro, and it controls the pager +display at the bottom (by default) of the factory list and search views/template. +It expects a C template argument which responds to the L interface. + +This macro is in the pager template and used as : + +[% PROCESS pager %] + +Maypole provides a pager for list and search actions, otherwise you can +provide a pager in the template using Template::Plugin::Pagination. + +[% USE pager = Pagination(objects, page.current, page.rows) %] +... +[% PROCESS pager %] + +The pager will use a the request action as the action in the url unless the +pager_action variable is set, which it will use instead if available. + +=head2 other macros =head1 AUTHOR diff --git a/templates/factory/pager b/templates/factory/pager index 6aed9c2..78c89fd 100644 --- a/templates/factory/pager +++ b/templates/factory/pager @@ -12,6 +12,10 @@ IF pager AND pager.first_page != pager.last_page; %]

Pages: [% + UNLESS pager_action; + SET pager_action = request.action; + END; + SET begin_page = pager.current_page - 10; IF begin_page < 1; SET begin_page = pager.first_page; @@ -30,14 +34,13 @@ IF pager AND pager.first_page != pager.last_page; IF request.params.order; SET args = args _ "&o2=desc" IF request.params.o2 == "desc"; - SET action = "list"; FOR col = classmetadata.columns.list; IF request.params.$col; SET args = args _ "&" _ col _ "=" _ request.params.$col; SET action = "search"; END; END; - link(classmetadata.table, action, args, label); + link(classmetadata.table, pager_action, args, label); END; END; %] -- 2.39.5