NAME
Egg::Plugin::Banner::Rotate - Plugin to display advertisement rotating.
SYNOPSIS
use Egg qw/ Banner::Rotate /;
my $banner= $e->banner_rotate->get_random('banner_name');
$e->stash->{head_banner}= qq{<a href="$banner->{url}"><img src="$banner->{img_url}" /></a>};
DESCRIPTION
The method that can be acquired by switching the data of the advertisement registered beforehand in every case is offered.
Please make a suitable data file for advertising data beforehand by the YAML format. This advertising data is a thing composed of ARRAY without fail.
---
url: http://banner/redirect/hoo.html
img_url: http://banner/images/hoo.gif
---
url: http://banner/redirect/hoge.html
img_url: http://banner/images/hoge.gif
The element in ARRAY is not very cared about. It only has to make data a convenient at the time of receipt format.
CONFIGURATION
The configuration is set with the key 'plugin_banner_rotate'.
plugin_banner_rotate => {
..........
....
},
base_dir
It is passing of the directory that sets up advertising data.
Default is "$e->config->{dir}{etc}/banners".
base_dir => '<e.dir.etc>/banners',
extention
Extension of advertising data file.
Default is 'yaml'.
extention => 'yaml',
METHODS
banner_rotate
The Egg::Plugin::Banner::Rotate::handler object is returned.
my $br= $e->banner_rotate;
HANDLER METHODS
Egg::Base has been succeeded to.
new
Constructor. When 'banner_rotate' method is called, it is called internally.
banners ([BANNER_NAME])
The registered advertising data is returned.
BANNER_NAME specifies the part of the file name that doesn't contain the extension of advertising data.
When BANNER_NAME is omitted, 'default' is used.
The data specified for BANNER_NAME should exist in "[base_dir]/[BANNER_NAME].[extention]".
If data file is not found, the exception is generated by 'LoadFile' of YAML.
The returned advertising data is HASH reference with the following keys.
banners = List data of advertisement (ARRAY_REF).
total = Registered advertising number.
time = time value when data is read.
num = Rotation number.
my $hash= $br->banners('banner_name');
for (@{$hash->{banners}}) {
.........
....
}
get_random ([BANNER_NAME])
Advertising data is returned from data obtained by 'banners' method at random. The argument is passed to 'banners' method.
my $banner= $br->get_random('hoge');
The element of ARRAY registered in YAML extends as it is in data.
get_turns ([BANNER_NAME])
Advertising data is sequentially returned from data obtained by 'banners' method. The argument is passed to 'banners' method.
my $banner= $br->get_turns('hoge');
The element of ARRAY registered in YAML extends as it is in data.
clear_cache ([BANNER_NAME])
This method clears it though 'banners' method uses cash.
When BANNER_NAME is specified, only the corresponding cash is cleared. When BANNER_NAME is unspecification, all cash is cleared.
$br->clear_cache('booo');
SEE ALSO
Egg::Release, Egg::Base, YAML,
AUTHOR
Masatoshi Mizuno <lushe@cpan.org>
COPYRIGHT AND LICENSE
Copyright (C) 2008 Bee Flag, Corp. <http://egg.bomcity.com/>.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.