1package Maypole::Component; 2use base 'Maypole'; 3use strict; 4use warnings; 5use vars qw($VERSION); $VERSION = '0.03'; 6use URI; use URI::QueryParam; 7 8sub component { 9 my ($r, $path) = @_; 10 my $self = bless { config => $r->config, parent => $r }, "Maypole::Component"; 11 my $url = URI->new($path); 12 $self->{path} = $url->path; 13 $self->parse_path; 14 $self->{query} = $url->query_form_hash; 15 $self->handler_guts; 16 $self->{output}; 17} 18 19sub get_template_root { shift->{parent}->get_template_root } 20sub view_object { shift->{parent}->view_object } 21 221; 23__END__ 24# Below is stub documentation for your module. You'd better edit it! 25 26=head1 NAME 27 28Maypole::Component - Run Maypole sub-requests as components 29 30=head1 SYNOPSIS 31 32 package BeerDB; 33 use base qw(Maypole::Component Apache::MVC); 34 35 36 [% request.component("/beer/view_as_component/20") %] 37 38=head1 DESCRIPTION 39 40This subclass of Maypole allows you to integrate the results of a Maypole 41request into an existing request. You'll need to set up actions and templates 42which return fragments of HTML rather than entire pages, but once you've 43done that, you can use the C<component> method of the Maypole request object 44to call those actions. You may pass a query string in the usual URL style. 45You should not fully qualify the Maypole URLs. 46 47=head1 SEE ALSO 48 49http://maypole.simon-cozens.org/ 50 51=head1 AUTHOR 52 53Simon Cozens, E<lt>simon@cpan.orgE<gt> 54 55=head1 COPYRIGHT AND LICENSE 56 57Copyright 2004 by Simon Cozens 58 59=cut 60