Gossamer Forum
Home : Products : Links 2.0 : Customization :

Build detailed only for new links?

Quote Reply
Build detailed only for new links?
Is it possible to build detailed pages for only new links (and not every single link)?

Thanks
Quote Reply
Re: [socrates] Build detailed only for new links? In reply to
Sure!
This should work, and there are likely other ways to do the job.

- First set the 'build detailed pages' option in links.cfg to '1':

# Detailed View: The script can build a single html page per link. This is
# great if you have a review in your database. To enable, you must set
# the directory where all the pages will be stored, the url to that directory
# and set the enable option.
$build_detailed = 1;
$build_detail_path = "$build_root_path/Detailed";
$build_detail_url = "$build_root_url/Detailed";

- You will also need to put a link to the detailed page in your template (search the forum for how-to).

- Then add the red to this sub in nph-build.pl:


sub build_detailed_view {
# --------------------------------------------------------
# This routine build a single page for every link.
#
my (@values, $id, %rec, $count);
if ($build_detail_path =~ m,^$build_root_path/(.*)$,) {
&build_dir ($1);
}
print "\t";
open (DB, "<$db_file_name") or &cgierr("unable to open database: $db_file_name. Reason: $!");
LINE: while (<DB>) {
/^#/ and next LINE; # Skip comment Lines.
/^\s*$/ and next LINE; # Skip blank lines.
chomp;
@values = &split_decode ($_);
$id = $values[$db_key_pos];
%rec = &array_to_hash (0, @values);
$title_linked = &build_linked_title ("$rec{'Category'}/$rec{'Title'}");
if ($rec{'isNew'} != 'No') { # isNew switch
open (DETAIL, ">$build_detail_path/$id$build_extension") or &cgierr ("Unable to build detail page: $build_detail_path/$id$build_extension. Reason: $!");
print DETAIL &site_html_detailed (%rec);
close DETAIL;
$use_html ?
print qq~<a href="$build_detail_url/$id$build_extension" target="_blank">$id</a> ~ :
print qq~$id ~;
(++$count % 10) or print "\n\t";
} # end isNew switch
}
close DB;
print "\n";
}


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] Build detailed only for new links? In reply to
Your link.html template should be like so:


<ul><li><a class="link" href="<%db_cgi_url%>/jump.cgi?ID=<%ID%>"><%Title%></a>
<%if isNew%>
<li><a href="/Detailed/<%ID%>.html">Detail Page</a>
<%endif%>

<%if Description%>
<span class="descript">- <%Description%></span>
<%endif%>
<%if isNew%>
<small><sup class="new">new</sup></small>
<%endif%>


This will show a link to the detail page only if the page is new.

Also, the line in the first post should look like this:

if ($rec{'isNew'} eq 'Yes') { # isNew switch


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] Build detailed only for new links? In reply to
Thanks - that's where I was trying to use the conditional statement but was using the wrong test for the New link (I was using$stats{$name}[4] = "Yes"; # new record flag).



Quote Reply
Re: [socrates] Build detailed only for new links? In reply to
PerlFlunkie,

I have another question. If I want to create an Index page for all detailed links, will something like this work in build_detailed_view?

(++$count % 10) or print "\n\t";
}
# Build the main Detailed page.
open (DETAIL, ">$build_detail_path/$build_index") or cgierr ("unable to open what's new page: $build_new_path/$build_index. Reason: $!");
print DETAIL &site_html_detailed (%rec);
close DETAIL;
}
close DB;
print "\n";
}


Thanks for your help.
Quote Reply
Re: [socrates] Build detailed only for new links? In reply to
I don't think so, it would be more invloved than that. The routine would need to calculate which links to include. You should be able to use the What's New page as an index.


Leonard
aka PerlFlunkie