
App::ZofCMS::Plugin::ConditionalRedirect - redirect users based on conditions

In Main Config file or ZofCMS template:
plugins => [ qw/ConditionalRedirect/ ],
plug_redirect => sub { time() % 2 ? 'http://google.com/' : undef },

The module is a plugin for App::ZofCMS. It provides means to redirect user to pages depending on certain conditions, e.g. some key having a value in ZofCMS Template hashref or anything else, really.
This documentation assumes you've read App::ZofCMS, App::ZofCMS::Config and App::ZofCMS::Template

plugins plugins => [ qw/ConditionalRedirect/ ],
plugins => [ { UserLogin => 1000 }, { ConditionalRedirect => 2000 } ],
The obvious is that you'd want to stick this plugin into the list of plugins to be executed. However, since functionality of this plugin can be easily implemented using exec and exec_before special keys in ZofCMS Template, being able to set the priority to when the plugin should be run would probably one of the reasons for you to use this plugin (it was for me at least).
plug_redirect plug_redirect => sub {
my ( $template_ref, $query_ref, $config_obj ) = @_;
return $template_ref->{foo} ? 'http://google.com/' : undef;
}
The plug_redirect first-level key in Main Config file or ZofCMS Template takes a subref as a value. The sub will be executed and its return value will determine where to redirect (if at all). Returning undef from this sub will NOT cause any redirects at all. Returning anything else will be taken as a URL to which to redirect and the plugin will call exit() after printing the redirect headers.
The @_ of the sub will receive the following: ZofCMS Template hashref, query parameters hashref and App::ZofCMS::Config object (in that order).
If you set plug_redirect in both Main Config File and ZofCMS Template, the one in ZofCMS Template will take precedence.

'Zoffix, <'zoffix at cpan.org'> (http://zoffix.com/, http://haslayout.net/, http://zofdesign.com/)

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

You can find documentation for this module with the perldoc command.
perldoc App::ZofCMS::Plugin::ConditionalRedirect
You can also look for information at:
http://rt.cpan.org/NoAuth/Bugs.html?Dist=App-ZofCMS-Plugin-ConditionalRedirect
http://annocpan.org/dist/App-ZofCMS-Plugin-ConditionalRedirect
http://cpanratings.perl.org/d/App-ZofCMS-Plugin-ConditionalRedirect
http://search.cpan.org/dist/App-ZofCMS-Plugin-ConditionalRedirect

Copyright 2008 'Zoffix, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.