David R. Baird
and 1 contributors

NAME

Maypole::Plugin::ColumnGroups - set up column groups in Maypole

SYNOPSIS

    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 ) ] }"

         

DESCRIPTION

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.

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.

Setting the Debug flag to 2 or higher will print some info to STDERR to confirm how the groups have been set up.

CONFIGURATION ACCESSORS

These methods are added to the Maypole configuration object.

column_groups
field_groups

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.

METHODS

setup

Sets up the CDBI column groups.

AUTHOR

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

BUGS

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.

ACKNOWLEDGEMENTS

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.