Gossamer Forum
Home : Products : Links 2.0 : Customization :

Show "Whats New" On Your Home Page

Quote Reply
Show "Whats New" On Your Home Page
Finaly I figured out how to show you whats new page on the home page. Well heres the code.
Where ever in your homepage you want the links to the new date in the new section, place this. $main_link_results
Open your nph-build.cgi find sub build_home_page { add this
# Now we go through all the new_links (which are organized by category), and
# build the html in array indexed by date then category.
$total = 0;
CATEGORY: foreach $category (sort keys %new_links) {
LINK: for ($i = 0; $i < ($#{$new_links{$category}}+1) / ($#db_cols + 1); $i++) {
$total++;
%tmp = &array_to_hash ($i, @{$new_links{$category}});
${$link_output{$tmp{'Date'}}}{$category} .= &site_html_link (%tmp) . "\n";
$span_totals{$tmp{'Date'}}++;
}
}

# Then we go through each date, and build the links for that date. If we are spanning
# pages, we will create a seperate page for each date and need to set up a few other
# variables (like title and total). We will also want to reset links_results each time.
DATE: foreach $date (sort { &date_to_unix($b) <=> &date_to_unix($a) } keys %link_output) {
$long_date = &long_date ($date);
if ($build_span_pages) {
$link_results = "";
$total = $span_totals{$date};
$title_linked = &build_linked_title ("New/$date");
}
else {
$link_results .= "<p><strong>$long_date</strong>\n<block quote>";
}
CATEGORY: foreach $category (sort keys %{$link_output{$date}}) {
$category_clean = &build_clean ($category);
$link_results .= qq|<P><A HREF="$build_root_url/$category/$build_index">$category_c lean</A>\n|;
$link_results .= ${$link_output{$date}}{$category};
}

# Crete the new page, and do a bit of HTML work for the main page.
if ($build_span_pages) {
open (NEW, ">$build_new_path/$date.htm") or cgierr ("unable to open what's new page: $build_new_path/$build_index. Reason: $!");
$use_html ?
print qq|\tNew Links for <a href="$build_new_url/$date.htm">$date</a>: $total\n| :
print qq|\tNew Links for $date: $total\n|;
print NEW &site_html_new;
close NEW;
$main_link_results .= qq|<a href="$build_new_url/$date.htm">$date</a> ($total).|;
$main_total += $total;
}
else {
$link_results .= "</blockquote>";
}
}

if ($build_span_pages) {
$link_results = "<ul>$main_link_results</ul>";
$total = $main_total;
}
$title_linked = &build_linked_title ("New");
between
my ($subcat, @rootcat);
local ($total);
and
# Check to see which categories are off of the root.
foreach $subcat (sort keys %category) {
if ($subcat =~ m,^([^/]*)$,) {
push (@rootcat, $subcat);
}
}
If you need any help let me know, you can see this in action at http://net-freebies.com/netrosearch
Thanks
Joey Bost
jbost@sheltonbbs.com