Description:
This box creates those nifty box closer links like you see on my.yahoo.com. Be careful with this. In order for it to operate correctly, you will need to place the call to this box inside the box template called 'box' (or whatever you're using as your main - most commonly used - box template), but in order to avoid an infinate loop, you will need to be sure that you use the box template 'empty_box' (or something other than your main box template) as the template for this box itself. The call to this box will in itself contain a variable substitution. the 'bid' variable' exists only for box templates and only in versions of Scoop 0.9-dev newer than April 6 2002
Box Code:
# Requires an image name to be defined in the variable 'hidebox_icon'
# This box should be called from within the box template 'box'
# The call should be of the form:
# |BOX,hidebox_box,|bid||
# an example box closer icon can be seen at:
# http://beta.evilplans.net/images/x.gif
### Really Start Hidebox Box ###
# Display a Box CLoser 'X' in box templates
# Version 0.1 by hillct
my($content);
my $uri=$S->apache->uri;
my $arg = $S->apache->args();
$arg =~ s/hide-box=\w+//g;
$arg =~ s/;$//;
my $redirect=($arg)?"$uri?$arg":$uri;
$uri .= ($arg) ? "?$arg;hide-box=$ARGS[0]" : "?hide-box=$ARGS[0]";
if($S->{GID} ne 'Anonymous') { # If logged in
if($S->cgi->param('hide-box')=~/$ARGS[0]/){
# Change the user pref for display of this box
$S->pref(displayed_boxes=>$S->pref('displayed_boxes').','.$ARGS[0]);
# Redirect because we're actually running the box
$S->apache->header_out('location',$redirect);
$S->apache->header_out('connection','close');
$S->apache->status(301); $S->{HEADER_ONLY}=1;
} else {
# Display an 'X' with a link to 'URI' if allowed
if($S->{BOX_DATA}{$ARGS[0]} && $S->{BOX_DATA}{$ARGS[0]}{user_choose}){
$content.=qq{<a href="$uri"><img src="$S->{UI}->{VARS}->{'rootdir'}$S->{UI}->{VARS}->{'imagedir'}/$S->{UI}->{VARS}->{'hidebox_icon'}" border="0" align="right" alt="close"></a>};
}
}
return {content => $content};
}
Announcement and Discussion
|