LastLinks on homepage and in a seperate lastlinks.html file ----------------------------------------------------------- By John Gotze In links.cfg ------------ Change # The name of an index file. $build_index = "index.html"; to # The name of an index file. $build_index = "index.html"; $build_lastlink = "lastlinks.html"; In site_html_templates.pl ------------------------- Change sub site_html_home to: sub site_html_home { # -------------------------------------------------------- # This routine will build a home page. It is not meant to have any # links on it, only subcategories. return &load_template ('home.html', { category => $category, grand_total => $grand_total, lastlink => $lastlink, %globals }); } And after this, add two new sub-routines: sub site_html_lastlink { # -------------------------------------------------------- # This routine is used to display what a link should look # like in the lastlink.html webpage. my %rec = @_; # Set new and pop to either 1 or 0 for templates. ($rec{'isNew'} eq 'Yes') ? ($rec{'isNew'} = 1) : (delete $rec{'isNew'}); ($rec{'isPopular'} eq 'Yes') ? ($rec{'isPopular'} = 1) : (delete $rec{'isPopular'}); return &load_template ('lastlink.html', { detailed_url => "$db_detailed_url/$rec{'ID'}$build_extension", %rec, %globals }); } sub site_html_lastlinkpage { # -------------------------------------------------------- # This routine will build a seperate last link page. return &load_template ('lastlinkpage.html', { category => $category, grand_total => $grand_total, lastlink2 => $lastlink2, %globals }); } In nph-build.cgi ---------------- Replace the build_home_page with this new sub-routine: sub build_home_page { # -------------------------------------------------------- my ($subcat, @rootcat); local ($total); # Check to see which categories are off of the root. foreach $subcat (sort keys %category) { if ($subcat =~ m,^([^/]*)$,) { push (@rootcat, $subcat); } } print "\tSubcategories: "; print $#rootcat+1; print "\n"; print "\tTotal Links: $grand_total\n"; print "\tOpening page: $build_root_path/$build_index\n"; my $LASTX = 5; my $LASTX2 = 5; open (DB, "<$db_file_name") or &cgierr ("unable to open database:$db_file_name.\nReason"); my @lines = ; close DB; for ($i=$#lines; $i>=$#lines - $LASTX; $i--) { chomp $lines[$i]; @tmp = &split_decode ($lines[$i]); %tmp = &array_to_hash (0, @tmp); $lastlink .= &site_html_link (%tmp); } for ($i=$#lines; $i>=$#lines - $LASTX2; $i--) { chomp $lines[$i]; @tmp2 = &split_decode ($lines[$i]); %tmp2 = &array_to_hash (0, @tmp2); $lastlink2 .= &site_html_lastlink (%tmp2); } open (HOME, ">$build_root_path/$build_index") or &cgierr ("unable to open home page: $build_root_path/$build_index. Reason: $!"); $category = &site_html_print_cat (@rootcat) if ($#rootcat >= 0); $total = $grand_total; print HOME &site_html_home; close HOME; print "\tClosing page.\n"; open (HOME, ">$build_root_path/$build_lastlink") or &cgierr ("unable to open home page: $build_root_path/$build_lastlink. Reason: $!"); print HOME &site_html_lastlinkpage; close HOME; print "\tClosing lastlink page.\n"; } Templates --------- Create two new templates: lastlink.html lastlinkpage.html Put them in the /templates directory. CHMOD 666. In home.html Use <%lastlink%> to insert the last links. In lastlinkpage.html A "complete" webpage with all the and stuff. Or, if used with SSI, nothing but <%lastlink2%> Use <%lastlink2%> to insert the last links in the format you want (defined in lastlink.html template). In lastlink.html Any variation of your link.html template. Just copy link.html if you don't want any changes. FAQ ---- Q: I get an error when building my pages after having installed this, what's wrong? A: Well, there can be many reasons, but the most common is that you don't have any links in your database. Add at least LASTX + 1 link, and try building your pages. If you still get an error, go through the complete install process again, and check and double-check everything. If it still fails, ask in the forum. I can give personal help by email, but have to charge you for that (I love amazon gift certificates!) Q: OK, I got it working, but I don't want 6 links. How do I change to, say 10 links? A: In the new sub-routine in nph-build.cgi, change my $LASTX = 5; my $LASTX2 = 5; to my $LASTX = 9; my $LASTX2 = 9; (yes, put 9, not 10, if you want 10 links ... don's ask why, that's just how it is ...) Q: I want 3 links at my homepage, but 10 at my lastlinks.html page. A: Change my $LASTX = 5; my $LASTX2 = 5; to my $LASTX = 2; my $LASTX2 = 9; //John