I need this table to be sortable by either a date or by one of two of the header fields. So much I have managed, albeit somewhat messily. What I can't do is when sorting by one of the header fields, I want to hide those html files that don't have anything in this particular header field. I cannot work out how to do it.
Relevant code I have so far is:
<snip>
#if the sortbydate flag is not activated, then carry out these instructions instead:
foreach $n (@html_list)
{
open (HTMLFILE,$n);
$author="";
$issue="";
$qart_code="";
$issue_date="";
$latest_changes="";
$title="";
# v0.06 Next line to read in whole paragraph; allow titles to be matched over lines
$/ = '';
while (<HTMLFILE>)
#v 1.10 Horrid stuff added in here for hiding/showing withdrawn docs
{
if ($incwithdrawn==1)
{
if (m/<o:Author>(.+)<\/o:Author>/i){$author=$1 };
if (m/<o:Keywords>(.+)<\/o:Keywords>/i){$issue=$1};
if (m/<o:Subject>(.+)<\/o:Subject>/i){$qart_code=$1};
if (m/<o:Description>(.+)<\/o:Description>/i){$issue_date=$1};
if (m/<o:Category>(.+)<\/o:Category>/i){$latest_changes=$1 };
# v0.06 /s modifier in next line ensures matching across lines
if (m/<TITLE>(.+)<\/TITLE>/si){$title=$1};
}
else
{
if (!(m/<o:Category>(.*?)Withdrawn(.*?)<\/o:Category>/i)) #if the file _isnot_ withdrawn
{
if (m/<o:Author>(.+)<\/o:Author>/i){$author=$1 };
if (m/<o:Keywords>(.+)<\/o:Keywords>/i){$issue=$1};
if (m/<o:Subject>(.+)<\/o:Subject>/i){$qart_code=$1};
if (m/<o:Description>(.+)<\/o:Description>/i){$issue_date=$1};
if (m/<o:Category>(.+)<\/o:Category>/i){$latest_changes=$1 };
# v0.06 /s modifier in next line ensures matching across lines
if (m/<TITLE>(.+)<\/TITLE>/si){$title=$1};
}
}
}
close HTMLFILE;
# Create link for main overview doc
if ($doc_code!~/\// && $doc_code!~/\./) #if it contains stops or slashes
{
$doc_code='<a href='.$QART_url.$out_subdir.'/'.$out_group.$out_subgroup.'.html>'.$doc_code.'</a>';
}
push(@rows, td([$doc_code,$title,$issue,$latest_changes,$issue_date,$author]));
}
print table({width=>"100%",border=>"0",bordercolor=>"#d9dae6",cellspacing=>"1",cellpadding=>"1"},Tr({bgcolor=>"#97a5f0"},\@rows));
<snip>
So, need when the "includewithdrawn" flag is not active, I do not want those html files whose "Category" field contains "withdrawn" to be included in my index. What is the easiest way to achieve this (have tried several different angles...)
apologies for roughness of it all!
Many thanx
$files->{'/showme.html'}->{'category'} = "cat1";
$files->{'/noshow.html'}->{'category'} = "withdrawn";
Then you can iterate through them as you'd like
[perl]
foreach my $i (keys %$files) {
print $i unless ($files->{$i}->{'category'} =~ /withdrawn)
}
[/perl]
Sean