NAME

Maypole::Plugin::QuickTable - HTML::QuickTable goodness for Maypole

SYNOPSIS

use Maypole::Application qw( QuickTable );

METHODS

setup
quick_table

Returns a HTML::QuickTable object for formatting data.

print $request->quick_table( %args )->render( $data );

The method gathers arguments from the quicktable_defaults method on the model class. This is a Class::Data::Inheritable method, so you can set global defaults on the main model class, and then override them in model subclasses. To preserve most settings and override others, say something like

$sub_model->quicktable_defaults( { %{ $model->quicktable_defaults }, %hash_of_overrides } );

Arguments passed in the method call override those stored on the model.

Pass a Maypole/CDBI object in the object slot, and its data will be extracted and $qt->render called for you:

print $request->quick_table( %args, object => $object );

Related objects will be displayed as links to their view template.

tabulate( $object|$arrayref_of_objects, %args )

Extract data from a Maypole/CDBI object (or multiple objects), ready to pass to quick_table->render. Data will start with a row of column names if $args{with_colnames} is true.

A callback subref can be passed in $args{callback}. It will be called in turn with each object as its argument. The result(s) of the call will be added to the row of data for that object. See the list template in Maypole::FormBuilder, which uses this technique to add edit and delete buttons to each row.

Arguments:

callback        coderef
with_colnames   boolean
fields          defaults to $object->display_columns

Template replacement methods

The following methods replace a couple of templates/macros in the main Maypole distribution. They are used here to construct links to related items. They are also used in the Maypole::FormBuilder templates.

Notice that if you build all paths using these methods in your templates, you can modify the path structure used in your site by overriding just two methods: Maypole::parse_path() and Maypole::Plugin::QuickTable::make_path().

Returns $thing unless it isa Maypole::Model::Base, in which case a link to the view template for the object is returned.

Runs multiple items through maybe_link_view, returning the results marked up as a list.

link( %args )

Returns a link, calling make_path to generate the path.

%args = ( table      => $table,
          action     => $action,        # called 'command' in the original link template
          additional => $additional,    # optional - generally an object ID
          label      => $label,
          );
make_path( %args )

This is the counterpart to Maypole::parse_path. It generates a path to use in links, form actions etc. To implement your own path scheme, just override this method and parse_path.

%args = ( table      => $table,
          action     => $action,        # called 'command' in the original link template
          additional => $additional,    # optional - generally an object ID
          );

AUTHOR

David Baird, <cpan@riverside-cms.co.uk>

BUGS

Please report any bugs or feature requests to bug-maypole-plugin-quicktable@rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Maypole-Plugin-QuickTable. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

COPYRIGHT & LICENSE

Copyright 2005 David Baird, All Rights Reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.