Egg::Plugin::Banner::Rotate - Plugin to display advertisement rotating.
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>};
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.
The configuration is set with the key 'plugin_banner_rotate'.
plugin_banner_rotate => { .......... .... },
It is passing of the directory that sets up advertising data.
Default is "$e->config->{dir}{etc}/banners".
base_dir => '<e.dir.etc>/banners',
Extension of advertising data file.
Default is 'yaml'.
extention => 'yaml',
The Egg::Plugin::Banner::Rotate::handler object is returned.
my $br= $e->banner_rotate;
Egg::Base has been succeeded to.
Constructor. When 'banner_rotate' method is called, it is called internally.
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}}) { ......... .... }
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.
Advertising data is sequentially returned from data obtained by 'banners' method. The argument is passed to 'banners' method.
my $banner= $br->get_turns('hoge');
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');
Egg::Release, Egg::Base, YAML,
Masatoshi Mizuno <lushe@cpan.org>
Copyright (C) 2008 Bee Flag, Corp. <http://egg.bomcity.com/>, All Rights Reserved.
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.
To install Egg::Release, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Egg::Release
CPAN shell
perl -MCPAN -e shell install Egg::Release
For more information on module installation, please visit the detailed CPAN module installation guide.