Hi,
I've written the enclosed sub to modify links that have been set as 'Enhanced' for more than 365 days.
It creates a modify form for each link, allowing me to decide which links I want to demote.
The problem I've got is that I can't seem to get the CategoryID number into the modify form (the link modification won't take without it).
Here's the generated HTML output:
<form method="POST" action="admin.cgi" name="admin">
<input type="hidden" name="db" value="Links">
<input type="hidden" name="do" value="modify_record">
<input type="hidden" name="ID" value="63">
<input type="hidden" name="CatLinks.CategoryID" value="ARRAY(0x8719a6c)">
<strong>63: LKW Walter</strong><br>
Added: 2002-08-16 - Difference: <em>1606</em>
isTop: <select name="isTop"><option value="3" selected>3</option></select>
<input type=submit value="Modify Record">
</form>
... and here's the sub ...
sub expire_enhanced {
# ------------------------------------------------------------------
# Check for links that have been enhanced for 365 days or more and
# change them to basic links
use Date::Simple ();
my $output = '';
my $today = GT::Date::date_get();
my $todaydate = Date::Simple->new($today);
my $cat_link = $DB->table('CatLinks');
my $sth = $DB->table('Links')->select( 'ID', 'Title', 'isValidated', 'Description', 'isTop', 'Add_Date');
print $IN->header();
while (my ($id, $title, $isval, $desc, $istop, $add) = $sth->fetchrow) {
my $adddate = Date::Simple->new($add);
my $datediff = $todaydate - $adddate;
if ($istop == 2) {
if ($datediff >= 365) {
my $catid = [$cat_link->select('CategoryID', { LinkID => $id })->fetchrow];
$output .= qq~
<form method="POST" action="admin.cgi" name="admin">
<input type="hidden" name="db" value="Links">
<input type="hidden" name="do" value="modify_record">
<input type="hidden" name="ID" value="$id">
<input type="hidden" name="CatLinks.CategoryID" value="$catid">
<strong>$id: $title</strong><br>
Added: $adddate - Difference: <em>$datediff</em>
isTop: <select name="isTop"><option value="3" selected>3</option></select>
<input type=submit value="Modify Record">
</form>
~;
}
}
}
return { output => $output };
}
Any idea where I've gone wrong?
Thanks in advance
Shaun
I've written the enclosed sub to modify links that have been set as 'Enhanced' for more than 365 days.
It creates a modify form for each link, allowing me to decide which links I want to demote.
The problem I've got is that I can't seem to get the CategoryID number into the modify form (the link modification won't take without it).
Here's the generated HTML output:
Code:
<form method="POST" action="admin.cgi" name="admin">
<input type="hidden" name="db" value="Links">
<input type="hidden" name="do" value="modify_record">
<input type="hidden" name="ID" value="63">
<input type="hidden" name="CatLinks.CategoryID" value="ARRAY(0x8719a6c)">
<strong>63: LKW Walter</strong><br>
Added: 2002-08-16 - Difference: <em>1606</em>
isTop: <select name="isTop"><option value="3" selected>3</option></select>
<input type=submit value="Modify Record">
</form>
... and here's the sub ...
Code:
sub expire_enhanced {
# ------------------------------------------------------------------
# Check for links that have been enhanced for 365 days or more and
# change them to basic links
use Date::Simple ();
my $output = '';
my $today = GT::Date::date_get();
my $todaydate = Date::Simple->new($today);
my $cat_link = $DB->table('CatLinks');
my $sth = $DB->table('Links')->select( 'ID', 'Title', 'isValidated', 'Description', 'isTop', 'Add_Date');
print $IN->header();
while (my ($id, $title, $isval, $desc, $istop, $add) = $sth->fetchrow) {
my $adddate = Date::Simple->new($add);
my $datediff = $todaydate - $adddate;
if ($istop == 2) {
if ($datediff >= 365) {
my $catid = [$cat_link->select('CategoryID', { LinkID => $id })->fetchrow];
$output .= qq~
<form method="POST" action="admin.cgi" name="admin">
<input type="hidden" name="db" value="Links">
<input type="hidden" name="do" value="modify_record">
<input type="hidden" name="ID" value="$id">
<input type="hidden" name="CatLinks.CategoryID" value="$catid">
<strong>$id: $title</strong><br>
Added: $adddate - Difference: <em>$datediff</em>
isTop: <select name="isTop"><option value="3" selected>3</option></select>
<input type=submit value="Modify Record">
</form>
~;
}
}
}
return { output => $output };
}
Any idea where I've gone wrong?
Thanks in advance

Shaun