# LastLink 1.99 # - a Links-mod for showing the X most recently added links on the homepage. # Templates Version # # Alex, Widgetz and oldmoney contributed to this mod. # John Gotze just wrote these instructions. This mod requires you to edit: * nph-build.cgi * site_html_templates.pl * and the home.html template Open nph-build.cgi and find sub build_home_page. Insert the following code after: print "\tOpening page: $build_root_path/$build_index\n"; [code] my $LASTX = 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); } [/code] See the "5" in the first line? That's the X. Well, the perl gods interpret this so that the script will insert the _6_ (X+1) most recent links on your homepage. This is a minor bug, but simple calculus will do just fine, i.e., if you want to show 9 links, set the first line to 8, and so forth. Now open site_html_templates.pl and find sub site_html_home. Insert this code: lastlink => $lastlink, You end up with something like: [code] 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 }); } [/code] OK, script editing done. Now edit your home.html template. Insert <%lastlink%> somewhere where you want to show the links. Save the template. Now Build pages. Look at your Links homepage - there you will now see the X most recent links! Done!