Gossamer Forum
Home : Products : Links 2.0 : Discussions :

Another question about links tree mod

Quote Reply
Another question about links tree mod
Hey guys !

Another question about links tree mod...
How can i build span pages in order to all links and categories are listed into pages with 10 links in each one of them?


# ****** tree modification - begin ******
sub build_tree_page {
# ---------------------------------------
# This routine builds a tree from all links/categories

my ($cat, $url, $dir, @related, $relation, $page_num, $next_page, $numlinks);
my ($linkstree, $output, @categorylist, $depth_old, $depth_new);
local ($category, $links, $title_linked, $title, $total, $category_name, $category_name_escaped);
local ($description, $related, $meta_name, $meta_keywords, $header, $footer, $next, $prev);

# set linkstree to 0 if you want only a tree off all categories
# set linkstree to 1 if you want a tree off all categories and links
$linkstree = 1;

$depth_old = 0;
$url = "$build_root_path/tree$build_extension";
open (CAT, ">$url") or &cgierr ("unable to open category page: $url. Reason: $!");

$output = qq~
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">

<style><!--A:link {text-decoration:none;}A:visited {text-decoration:none;}A:hover {text-decoration:underline;}--></style>

<body bgcolor="#FFFFFF" text="#000000" LINK="#000099" VLINK="#000099" ALINK="#000099">

<CENTER><IMG SRC="http://www.taservido.com.br/taservido.gif" BORDER=0 HEIGHT=163 WIDTH=400></CENTER>
<BR><CENTER><A HREF="http://www.taservido.com.br/publicidade/index.html" target="blank"><IMG SRC="http://www.taservido.com.br/anuncie.gif" ALT="Anuncie aqui" BORDER=1 HEIGHT=40 WIDTH=400></A></CENTER>
<CENTER><table border=0 WIDTH="60%" CELLSPACING=1>
<tr BGCOLOR="#FFFFCC"><td align="center" BGCOLOR="#FFFFCC"><FONT FACE="Arial" SIZE=-1>Total de estabelecimentos cadastrados: <B>$grand_total</B>.</tr></td></FONT></CENTER></TABLE></CENTER>
print CAT $output;

# Go through each category and build the appropriate page.
CATEGORY: foreach $cat (sort keys %category) {
next CATEGORY if ($cat =~ /^\s*$/); # How'd that get in here? =)

# We set up all the variables people can use in &site_html.pl.
($description, $related, $meta_name, $meta_keywords, $header, $footer) = @{$category{$cat}}[2..7];

$title_linked = &build_linked_title ($cat);
$title = &build_unlinked_title ($cat);
$total = ($#{$links{$cat}} + 1) / ($#db_cols + 1);
$category_name = $cat;
$category_name_escaped = &urlencode ($cat);
$category_clean = &build_clean ($cat);

$numlinks = ($#{$links{$cat}} + 1) / ($#db_cols + 1);
@categorylist = split (/\//, $cat);
$depth_new = $#categorylist;
$links = "";
if ($depth_new < $depth_old) {
for ($i = 0; $i <= ($depth_old - ($depth_new + 1)); $i++) {
$links .= "\n</ul>";

$links .= qq~\n<p align="center"><table align="center" border=0 WIDTH="60%" CELLSPACING=1><tr><td align="center"><P ALIGN="LEFT"><FONT FACE="Verdana" SIZE=-1 COLOR="#CC0000">$title</FONT></td></tr></table><BR>~;
if ($linkstree == 1) {
for ($i = 0; $i < $numlinks; $i++) {
%tmp = &array_to_hash ($i, @{$links{$cat}});
$links .= &site_html_link_tree (%tmp);
$links .= "\n";

if ($#{$subcategories{$cat}} >= 0) {
$links .= "\n";

print CAT $links;
$depth_old = $depth_new;

$output = qq~

<form action="$build_search_url" method="GET">
<div class="margin">
<table border="0" cellspacing="0" cellpadding="0">
<tr><td> <img src="http://www.taservido.com.br/nbusca.jpg"> <input type="text" size=20 name="query"> <input type=submit value="Procurar"></td></tr>

<CENTER><hr width="55%" noshade size="2"></CENTER>
<CENTER><small class="update"><font face="arial, helvetica" size="1" color="#000000">Última atualização em :</FONT><FONT face="arial, helvetica" size="1" COLOR="#FF0000"> $date </FONT><FONT face="arial, helvetica" size="1" COLOR="#000000">-</FONT><FONT face="arial, helvetica" size="1"><FONT COLOR="#FF0000"> $time</FONT><br>
<a href="http://www.taservido.com.br">Tá Servido?</a></FONT><font face="arial, helvetica" size="1" color="#000000"> - Todos os direitos reservados - 1999 ©<BR>
Webmaster: <a href="mailto:webmaster\@taservido.com.br">Bruno Gargaglione</a></font></CENTER></SMALL>

print CAT $output;

close CAT;
# ****** tree modification - end ******

[This message has been edited by Traven (edited February 01, 2000).]