I would like to modify category display on a Perl script directory. Pages are generated in html. Categories are displayed on only one column in a cell. I would like to place them in two columns like Dmoz directory.
I think that I have to divide my $catindex variable by something like these two $catindex1 and $catindex2.
Is there somebody that could tell me how to write the part of the script need to achieve this?
Thank you
gjfortin
#
$CatCols = 2; # number of columns desired (2)
open (CAT,"$cat_file"); # text file, 1 cat per line
seek (CAT,0,0);
@lines = <CAT>;
$ttlcat = scalar(@lines);
$CatsPerCol = int($ttlcat / $CatCols);
seek (CAT,0,0);
print "<TABLE>\n";
print "<TR>\n";
print "<TD valign=top align=left>\n";
$num = "0";
while ($rec = <CAT>) {
print "$rec<BR>";
if ("$num" eq "$CatsPerCol") {
print "</TD>\n";
print "<TD valign=top align=left>\n";
$num = '0';
}
$num++
}
print "</TD>\n";
print "</TR>\n";
print "</TABLE>\n";
close (CAT);
#
I realized that this directory script is writing directly into the html pages that are already created. There are no db nor text file created.
Do you think that it is possible to divide categories directly into the part of the script below?
Thank you for your help,
gjfortin
########################
# categorys processing.
sub categpro {
if ("$categorys" eq "")
{ print "alert no data input. please return <a href='$rel?pwd'>click here</a>."; }
else {
$out = "1";
&adcontrol;
$categorys =~ s/[\?\*\+\^\$\¦\\\(\)\[\]\{\}\"\'\/§´`~><°%µ=;,:&]//g;
$categorys =~ s/^\s+//; $categorys =~ s/\s+$//;
$categorys =~ tr/ /-/;
open (CATP,"$userdirectory/category.txt");
@catp = <CATP>;
close(CATP);
@catpc = @catp;
$catpc = shift(@catpc); chomp($catpc);
if ("$catpc" eq "no_category_available") { shift(@catp); } else {}
foreach $catp (@catp) { chomp($catp);
if ("$catp" eq "$categorys") { $foundcat = "1"; print "<h2>category <i>$categorys</i> allready exists.</h2>"; } else {} }
if ("$foundcat" eq "1") { $foundcat = "0"; }
else { push(@catp, $categorys);
open (CATP,">$userdirectory/category.txt");
foreach $catp1 (@catp) { print CATP "$catp1\n"; }
close(CATP);
# create/update html templates.
# categorys html.
open (CATHTML,">$homepath/$categorys.html");
print CATHTML &htmlcat;
close(CATHTML);
# add html.
@options = ();
foreach $catp2 (@catp) { $options = "<option>$catp2</option>"; push(@options, $options); }
open (ADDHTML,">$homepath/add.htm");
print ADDHTML &htmladd;
close(ADDHTML);
# index html.
open (INDEXHTML,">$homepath/index.htm"); $countcl = 0;
@catindex = ();
foreach $catp2 (@catp) { $countcl++;
$catin = "<a href='$catp2.html'><h4>$countcl¦ $catp2 :: click here for websites in category</h4></a>";
push(@catindex, $catin); }
$catindex = "
<table border=1 bordercolor='$boco' cellspacing=0 cellpadding=3 width=500 bgcolor='$taba'>\n
<tr><td bgcolor='$tabg'><font color='$fontc' size=5><b>index :: $countcl categorys online</b></font></td></tr><tr><td><p><br>\n@catindex\n</td></tr></table>\n";
print INDEXHTML &htmlindex;
close(INDEXHTML); }
if ("$noquit" eq "yes") {}
else { $validcontrol = "$admincontrol"; &meme; }}}
#############
There is effectively a category.text file in /userdirectory/ containing only name of the categories already created, one category per line but there is no .text file on my server containing registered links in these categories. Accepted links are not written in a data base but directly written on specific html pages.
Html pages are not located like the last line of your previous answer in /userdirectory/categorys.html but outsite of the cgi-bin folder like this: www/directory/index.htm.
Do you think it is possible to split each category line of the category.txt in two different td into the index html page? Each category appearing on the html page begins by a different number like this 1¦ Arts… but without number in the category.txt file.
Thank you.
Do you think it is possible to split each category line of the category.txt in two different td into the index
That's what the snip I posted does... It writes out the HTML in (2) or more columns... What may have been confusing is rather than alternate the categroies left and right on each line-
ARTS BOOK
CATS DOGS
EGGS FUNK
it calculates the total number of categories then splits them into <TD>'s like this-
ARTS DOGS
BOOK EGGS
CATS FUNK
I think its much easier to scan down an alphabetical list (eye can scan down the list instead of left/right back and forth as you scan down which gives you ping-pong brain)...
Alternativly, the code would produce (3) columns as-
ARTS CATS EGGS
BOOK DOGS FUNK
You just need to find where the script is writing and put the routin in there --- it might help to stick a line like-
print "*** TEST ****";
into the code, run it and see where it shows up... once you can get the "*** TEST ***" to appear next to the category names it will be easy to work the code.