Gossamer Forum
Home : Products : Links 2.0 : Discussions :

categories on different page

Quote Reply
categories on different page
how can I place the main categories on a different page like the main page in my site

is there a way of calling only the categories using SSI

please help me with this guys

Quote Reply
Re: categories on different page In reply to
You could -

1. If you don't need the main Links start page, simpley edit you home.html template to only contain <%category%>. Then call /pages/index.html with SSI from your startpage.

2. If you want to build a special page with only the categories and nothing else, you will need to do a rather extensive, but not very difficult modification, going something like this:

In links.cfg
# The name of an index file.
$build_index = "index.html";
$build_catsonly = "catsonly.html";

In site_html_templates.pl, add a new sub site_html_catsonly based on site_html_home, but load a new template, say catsonly.html, instead of home.html.
Create the catsonly.html template. This should only have <%category%> in it.

In nph-build.cgi add something like
# Create a page with only the categories..
print "Building the catsonly page. . .\n";
&build_catsonly_page;
print "Done.\n\n";

Add a new sub, something like
In Reply To:
sub build_catsonly_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_catsonly\n";

open (HOME, ">$build_root_path/$build_catsonly") or &cgierr ("unable to open home page: $build_root_path/$build_catsonly. Reason: $!");
$category = &site_html_print_cat (@rootcat) if ($#rootcat >= 0);
$total = $grand_total;
print HOME &site_html_catsonly;
close HOME;
print "\tClosing page.\n";
}
That should do it, I think.

Quote Reply
Re: categories on different page In reply to
thanks alot it did the job ...but is there is a way of having the links on this new page only in one colum ...

and again thanks alot

Quote Reply
Re: categories on different page In reply to
You can add a new subroutine in your site_html_templates.pl with something like:
Code:
sub site_html_print_catsonly {
# --------------------------------------------------------
# This routine determines how the list of categories will look.
# We now use a table to split the category name up into two columns.
# For each category you can use the following variables:
#
# $url : The URL to go to that category
# $category_name : The category name with _ and / removed.
# $category_descriptions{$subcat}: The category description (if any).
# $numlinks : The number of links inside that category (and subcategories).
# $mod : The newest link inside of that category.
#

my (@subcat) = @_;
my ($url, $numlinks, $mod, $subcat, $category_name, $description, $output, $i);

foreach $subcat (sort @subcat) {
($description) = @{$category{$subcat}}[2];

# First let's get the name, number of links, and last modified date...
$url = "$build_root_url/" . &urlencode($subcat) . "/";
if ($subcat =~ m,.*/([^/]+)$,) { $category_name = &build_clean($1); } else { $category_name = &build_clean($subcat); }
$numlinks = $stats{"$subcat"}[0];
$mod = $stats{"$subcat"}[1];

# Then we print out the name linked, new if it's new, and popular if its popular.
$output .= qq|<strong><a class="link" href="$url">$category_name</a></strong> <small class="numlinks">($numlinks)</small> |;
$output .= qq|<small><sup class="new">new</sup></small>| if (&days_old($mod) < $db_new_cutoff);
$output .= qq|$description | if (!($description =~ /^[\s\n]*$/));
$output .= qq|<p>|;
}

return $output;
}
Then call this sub instead of site_html_print_cat in the sub build_catsonly_page I gave above, i.e.:
$category = &site_html_print_catsonly (@rootcat) if ($#rootcat >= 0);

That should do it, I think.


Quote Reply
Re: [gotze] categories on different page In reply to
Anyone working this with Version: 3.2.0

And if so will you share you code?

Thanks
SandraR


Sandra Roussel
Chonsa Group Design - Fresh Start Housing