Gossamer Forum
Home : Products : Links 2.0 : Customization :

auto generating aditional text files for SSI inclusion in non Links pages

Quote Reply
auto generating aditional text files for SSI inclusion in non Links pages
I looked for about and hours through the previous posts on similar topics but none aswered my question.



Is there a way to mod Links 2.0 so that it creates additiona text files so that these text file can be called upon via SSI by pages on the site that are NOT generated by Links.

Suppose I want to list the top 10 links on my home page grab a random link and showcase it on the main page.

Any suggestion?
Quote Reply
Re: [snookie] auto generating aditional text files for SSI inclusion in non Links pages In reply to
to answer your specific question on the top 10 on your home page, see the post on this very subject dated yesterday May 2...

http://www.gossamer-threads.com/...psed;page=last;#last

search for the word random

actualy, with a slight modification to Pauls' topx mod in that post, you could probably use it to generate your random link.


Gene
"The older I get, the more I admire competence, just simple competence in any field from adultery to zoology."
Quote Reply
Re: [snookie] auto generating aditional text files for SSI inclusion in non Links pages In reply to
How familiar are you with Links? Comfortable messin' with the code? In nph-build.pl, find the sub build_new_page routine. Look for this:

# Build the main What's New page.
open (NEW, ">$build_new_path/$build_index") or cgierr ("unable to open what's new page: $build_new_path/$build_index. Reason: $!");
print "\tTotal New Links: $total\n";
print NEW &site_html_new(@new_links);
close NEW;
}

Put a copy of it below there, with these changes:

# Build the main What's New.txt page.
open (NEW, ">$build_new_txt_path/$build_index") or cgierr ("unable to open what's new page: $build_new_txt_path/$build_index. Reason: $!");
print "\tTotal New Links: $total\n";
print NEW &site_html_new_txt(@new_links);
close NEW;
}

Next, in links.cfg, add this (in addition to the others):

# PATH and URL of What's New.txt page. No Trailing slash.
$build_new_txt_path = "$build_root_path/new.txt";
$build_new_txt_url = "$build_root_url/new.txt";

Now go to site_html_templates.pl, and add this (in addition to existing sub):

sub site_html_new_txt {
# --------------------------------------------------------
# This routine will build a what's new.txt page.

return &load_template ('new.txt', {
total => $total,
grand_total => $grand_total,
link_results => $link_results,
title_linked => $title_linked,
%globals
} );
}

Finally, create a new template named new.txt, with this in it:

<h2><%total%> New Links:</h2>
<%link_results%>


This SHOULD create a text file containing what you want, and it can be called using SSI pointed to something like /links/pages/new.txt/index.html (depends on your setup). The link called in by the SSI will then point to the "New" pages created by Links (... .com/links/pages/New/4-May-2003.html).

I tested this on my test site, and I made a minor change to the sub in nph-build above. Also, you need to manually create the new.txt directory. Yes, it will work. If this is not exactly what you want, it should give you an idea of how to get there, anyway...


Leonard
aka PerlFlunkie

Last edited by:

PerlFlunkie: May 4, 2003, 12:42 AM
Quote Reply
Re: [PerlFlunkie] auto generating aditional text files for SSI inclusion in non Links pages In reply to
this seems to be exactly what I was trying to do :). I provably wont have a chace to test it tonight but it does semm to be what I was looking for :) thank you!
Quote Reply
Re: [snookie] auto generating aditional text files for SSI inclusion in non Links pages In reply to
I forgot to mention that in nph-build, when the sub is copied in, remove the closing bracket from what was the last sub...the red one here:

# Build the main What's New page.
open (NEW, ">$build_new_path/$build_index") or cgierr ("unable to open what's new page: $build_new_path/$build_index. Reason: $!");
print "\tTotal New Links: $total\n";
print NEW &site_html_new(@new_links);
close NEW;
}


Otherwise, you will not be able to build your pages...


Leonard
aka PerlFlunkie