Gossamer Forum
Home : Products : Links 2.0 : Customization :

Sorting on What's New Page

Quote Reply
Sorting on What's New Page
Hi

I was able to change how the categories look on the What's New page by showing the last category only so:
Category : Sub Category : Last Category
now looks like:
Last Category

The problem is, the page is still sorted by Category : Sub Category : Last Category,
I would like to sort it by Last Category

Anyone have any ideas of how to do this?

George
Quote Reply
Re: [macbethgr] Sorting on What's New Page In reply to
You could try the 'sort by relevance' (name?) mod from the resource section, but apply it to the new page only. Again, just pointing, not sure how to implement. But I do have that mod on my site, and I have the cats sorted how I want hem, not alphabetical. I have it set to use a new field with a ranking number (1 shows first, 2 second, etc), but you can tell it which field to sort by, also.

Ya did good figurin' your last question, so no doubt you'll get this one, too!Smile


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] Sorting on What's New Page In reply to
Thanks,

I did look at that, but still unable to figure it out.... I am really stumped on this one.... any help would really be appriciated.

George

Last edited by:

macbethgr: Nov 14, 2002, 5:59 AM
Quote Reply
Re: [macbethgr] Sorting on What's New Page In reply to
Try this bit, have no idea if it'll work, though. Changes in red. Maybe it'll give ya some direction...?

Code:

sub build_new_page {
# --------------------------------------------------------
# Creates a "What's New" page. Set $build_span_pages to 1 in links.cfg
# and it will create a seperate page for each date.
#
my (%link_output, $category_clean, $long_date, $category, $date,
$number_links, $main_link_results, $main_total, %span_totals);
local ($total, $link_results, $title_linked); # Let's build the What's New directory.
if ($build_new_path =~ m,^$build_root_path/(.*)$,) {
&build_dir ($1);
}

# 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 $subcategory (sort keys %new_links) { LINK: for ($i = 0; $i < ($#{$new_links{$subcategory}}+1) / ($#db_cols + 1); $i++) {
$total++;
%tmp = &array_to_hash ($i, @{$new_links{$subcategory}});
${$link_output{$tmp{'Date'}}}{$subcategory} .= &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<blockquote>";
}
CATEGORY: foreach $subcategory (sort keys %{$link_output{$date}}) {
$category_clean = &build_clean ($subcategory);
$link_results .= qq|<P><A HREF="$build_root_url/$subcategory/$build_index">$category_clean</A>\n|;
$link_results .= ${$link_output{$date}}{$subcategory};
}


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] Sorting on What's New Page In reply to
$subcategory is not defined anywhere.
Quote Reply
Re: [macbethgr] Sorting on What's New Page In reply to
Yeah, I thought about that, and at first I had included it in the "my" statement, but I didn't see it that way in any of the other subs. Subcats is a temp database, looks like. Looking through the code above "new" subroutine I find things like this:

Code:
foreach $cat ( keys %subcategories ) {
@{$subcategories{$cat}} = sort @{$subcategories{$cat}};
and
Code:
# Check to see which categories are off of the root.
foreach $subcat (sort keys %category) {
if ($subcat =~ m,^([^/]*)$,) {
push (@rootcat, $subcat);
}
}
So, maybe adding one of those into the "new" sub would fix it...?


Leonard
aka PerlFlunkie