Gossamer Forum
Home : Products : Links 2.0 : Customization :

Nph_Build

Quote Reply
Nph_Build
Okay

I searched the posts and kinda found the answer to this question but can't get it to work.

I want the more pages to be named what the category name is. So instead of more2.html it should be electronics2.html.

Now in nph_build I replaced all the more code with $cat. When I build it the links come out right but no pages get built with those names.

Some help here would be great.Smile

Thanks
Quote Reply
Re: [bytor] Nph_Build In reply to
sub build_category_pages recognizes these tags:

$category_name = $cat;
$category_name_escaped = &urlencode ($cat);
$category_clean = &build_clean ($cat);

So, try changing this code:

Code:

# If we are spanning pages, we grab the first x number of links and build
# the main index page. We set $numlinks to the remaining links, and we remove
# the links from the list.
$numlinks = ($#{$links{$cat}} + 1) / ($#db_cols + 1);
$next = $prev = $links = "";
if (($numlinks > $build_links_per_page) && $build_span_pages) {
$page_num = 2;
$next = $url . "$category_name_escaped_$page_num$build_extension";
for ($i = 0; $i < $build_links_per_page; $i++) {
%tmp = &array_to_hash ($i, @{$links{$cat}});
$links .= &site_html_link (%tmp);
}
@{$links{$cat}} = @{$links{$cat}}[(($#db_cols+1)*$build_links_per_page) .. $#{$links{$cat}}];
$numlinks = ($#{$links{$cat}}+1) / ($#db_cols + 1);
}
# Otherwise we either only have less then x number of links, or we are not
# splitting pages, so let's just build them all.
else {
for ($i = 0; $i < $numlinks; $i++) {
%tmp = &array_to_hash ($i, @{$links{$cat}});
$links .= &site_html_link (%tmp);
}
}
# Create the main page.
open (CAT, ">$dir/$build_index") or &cgierr ("unable to open category page: $dir/$build_index. Reason: $!");
print CAT &site_html_category;
close CAT;
# Then we go through the list of links and build on the remaining pages.
$prev = $url if ($build_span_pages);
while ($next && $build_span_pages) {
if ($numlinks > $build_links_per_page) {
$next_page = $page_num+1;
$next = $url . "$category_name_escaped_$next_page$build_extension";
}
else {
$next = "";
}
$links = "";
LINK: for ($i = 0; $i < $build_links_per_page; $i++) {
%tmp = &array_to_hash ($i, @{$links{$cat}});
last LINK if ($tmp{$db_key} eq "");
$links .= &site_html_link (%tmp);
}
$title_linked = &build_linked_title ("$cat/Page_$page_num/");
$title = &build_unlinked_title ("$cat/Page_$page_num/");

$use_html ?
print qq|\tSubpage : <A HREF="|, $url, qq|$category_name_escaped_$page_num$build_extension" TARGET="_blank">$dir/$category_clean_$page_num$build_extension</A>\n| :
print qq|\tSubpage : $dir/$category_name_escaped_$page_num$build_extension\n|;

open (CAT, ">$dir/$category_name_escaped_$page_num$build_extension") or &cgierr ("unable to open category page: $dir/index$page_num$build_extension. Reason: $!");
print CAT &site_html_category;
close CAT;
@{$links{$cat}} = @{$links{$cat}}[(($#db_cols+1)*$build_links_per_page) .. $#{$links{$cat}}];
$numlinks = ($#{$links{$cat}}+1) / ($#db_cols + 1);

$prev = $url . "$category_name_escaped_$page_num$build_extension";
$page_num++;
}
print "\n";
}
}








Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] Nph_Build In reply to
This did not work for me.Frown