# If we are spanning pages, we grab the first x number of links and build # the main index page. We set $numlinks to the remaining links, and we remove # the links from the list. $numlinks = ($#{$links{$cat}} + 1) / ($#db_cols + 1); $next = $prev = $links = ""; if (($numlinks > $build_links_per_page) && $build_span_pages) { $page_num = 2; $next = $url . "more$page_num$build_extension"; # added 01-14-01 2 column layout for link listings by mainstop.com $column_2 = "0"; for ($i = 0; $i < $build_links_per_page; $i++) { %tmp = &array_to_hash ($i, @{$links{$cat}}); if ($column_2 ne "1") { $column_2 = "1"; $links .= "\n"; $links .= &site_html_link (%tmp); $links .= "\n"; } else { $column_2 = "0"; $links .= "\n"; $links .= &site_html_link (%tmp); $links .= "\n"; } } @{$links{$cat}} = @{$links{$cat}}[(($#db_cols+1)*$build_links_per_page) .. $#{$links{$cat}}]; $numlinks = ($#{$links{$cat}}+1) / ($#db_cols + 1); } # Otherwise we either only have less then x number of links, or we are not # splitting pages, so let's just build them all. else { $column_2 = "0"; for ($i = 0; $i < $numlinks; $i++) { %tmp = &array_to_hash ($i, @{$links{$cat}}); if ($column_2 ne "1") { $column_2 = "1"; $links .= "\n"; $links .= &site_html_link (%tmp); $links .= "\n"; } else { $column_2 = "0"; $links .= "\n"; $links .= &site_html_link (%tmp); $links .= "\n"; } } if (int($numlinks/2) != ($numlinks/2)) { $links .= "\n"; } } # Create the main page. open (CAT, ">$dir/$build_index") or &cgierr ("unable to open category page: $dir/$build_index. Reason: $!"); print CAT &site_html_category; close CAT; # Then we go through the list of links and build on the remaining pages. $prev = $url if ($build_span_pages); while ($next && $build_span_pages) { if ($numlinks > $build_links_per_page) { $next_page = $page_num+1; $next = $url . "more$next_page$build_extension"; } else { $next = ""; } $links = ""; LINK: for ($i = 0; $i < $build_links_per_page; $i++) { %tmp = &array_to_hash ($i, @{$links{$cat}}); last LINK if ($tmp{$db_key} eq ""); if ($column_2 ne "1") { $column_2 = "1"; $links .= "\n"; $links .= &site_html_link (%tmp); $links .= "\n"; } else { $column_2 = "0"; $links .= "\n"; $links .= &site_html_link (%tmp); $links .= "\n"; } } if (int($numlinks/2) != ($numlinks/2)) { $links .= "\n"; } $title_linked = &build_linked_title ("$cat/Page_$page_num/"); $title = &build_unlinked_title ("$cat/Page_$page_num/");