David R. Baird > Maypole-Plugin-LinkTools-0.21 > Maypole::Plugin::LinkTools

Download:
Maypole-Plugin-LinkTools-0.21.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  2
Open  0
View Bugs
Report a bug
Module Version: 0.21   Source  

NAME ^

Maypole::Plugin::LinkTools - convenient link construction

SYNOPSIS ^

    use Maypole::Application qw( LinkTools );
    
    #...
    
    print $request->maybe_link_view( $thing );
    
    print $request->maybe_many_link_views( @things );
    
    print $request->link( table      => $table,
                          action     => $action,        # called 'command' in the original link template
                          additional => $additional,    # optional - generally an object ID
                          label      => $label,
                          );
                          
    print $request->make_path( table      => $table,
                               action     => $action,        # called 'command' in the original link template
                               additional => $additional,    # optional - generally an object ID
                               );

DESCRIPTION ^

Provides convenient replacements for the link and maybe_link_view templates, and a new maybe_many_link_views method.

Centralises all path manipulation, so that a new URI scheme can be implemented site-wide by overriding just two methods (Maypole::parse_path() and Maypole::Plugin::LinkTools::make_path()).

For ease of use with the Template Toolkit, make_path, link and link_view will also accept a hashref of arguments. For example:

    print $request->make_path({ table      => $table,
                                action     => $action,
                                additional => $additional,
                             });

METHODS ^

make_path( %args or \%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
              );

id can be used as an alternative key to additional.

link( %args or \%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,
              );

The table can be omitted and defaults to that of the request's model. id can be used as an alternative key to additional.

link_view( $thing or %args or \%args )

Build a link to the view action of the given item. If passed a Maypole request object, builds a link to its view action.

    print $request->link_view( $maypole_request );
    
    print $request->link_view( table      => $table,
                               label      => $label,
                               additional => $id,
                               );
maybe_link_view( $thing )

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

maybe_many_link_views

Runs multiple items through maybe_link_view, returning a list.

AUTHOR ^

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

BUGS ^

Please report any bugs or feature requests to bug-maypole-plugin-linktools@rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Maypole-Plugin-LinkTools. 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.