Maypole::Plugin::ColumnGroups - set up column groups in Maypole
use Maypole::Application qw( ColumnGroups -Debug2 ); # Maypole will use the column 'name' or 'title', if it exists, or a primary # key column that is not called 'id'. Otherwise, you need to tell Maypole # what column to stringify objects to: __PACKAGE__->config->column_groups( { person => { Stringify => 'first_name' }, car => { Stringify => 'model' }, widget => { Stringify => 'part_no' }, article => { Editor => [ qw( content keywords publish location ) ], Writer => [ qw( content keywords ) ], Reviewer => [ qw( rating ) ], }, finance => { Editor => [ qw( invoice credit bribe entertainment ) ] }, } ); # # An example using Maypole::Plugin::Config::Apache: # PerlAddVar MaypoleColumnGroups "person => { Stringify => 'first_name' }" PerlAddVar MaypoleColumnGroups "car => { Stringify => 'model' }" PerlAddVar MaypoleColumnGroups "widget => { Stringify => 'part_no' }" PerlAddVar MaypoleColumnGroups "article => { Editor => [ qw( content keywords publish location ) ] }" PerlAddVar MaypoleColumnGroups "article => { Writer => [ qw( content keywords ) ] }" PerlAddVar MaypoleColumnGroups "article => { Reviewer => [ qw( rating ) ] }" PerlAddVar MaypoleColumnGroups "finance => { Editor => [ qw( invoice credit bribe entertainment ) ] }"
Maypole use the Stringify column group to decide which column to use when, for example, displaying a link to an object. If there is no Stringify group, Maypole defaults to using the column 'name' or 'title', if it exists, or a primary key column that is not called 'id'. Otherwise, you need to tell Maypole what column to stringify objects on.
Stringify
Authorization could make heavy use of column groups to decide who has access to what columns of different tables. It's easy enough to set up column groups by hand, but it's also useful to be able to stuff all that information into the configuration data.
Maypole::FormBuilder defines several pairs of *_columns and *_fields accessors in the model class, generally one pair for each main template (view, edit, addnew etc.). You could override these methods to look up their lists in the column_groups and field_groups config slots.
*_columns
*_fields
view
edit
addnew
column_groups
field_groups
Setting the Debug flag to 2 or higher will print some info to STDERR to confirm how the groups have been set up.
Debug
STDERR
These methods are added to the Maypole configuration object.
You may wish to use this slot to store information about different groups of non-column fields. For instance, just as display_columns returns a list of columns for general display in templates, you may wish to define a display_fields method to list has_many accessors to use in the same circumstances. This config slot provides a convenient location to store that information.
display_columns
display_fields
has_many
Sets up the CDBI column groups.
David Baird, <cpan@riverside-cms.co.uk>
<cpan@riverside-cms.co.uk>
Please report any bugs or feature requests to bug-maypole-plugin-columngroups@rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Maypole-Plugin-ColumnGroups. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-maypole-plugin-columngroups@rt.cpan.org
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.
To install Maypole::Plugin::ColumnGroups, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Maypole::Plugin::ColumnGroups
CPAN shell
perl -MCPAN -e shell install Maypole::Plugin::ColumnGroups
For more information on module installation, please visit the detailed CPAN module installation guide.