NewsPro FAQ

NewsPro FAQ > Customisation >
How can I post my news on another site or server?

 

There is a way to post your news on another site. It isn't perfect, though. The news doesn't actually get included on the page; the browser fetches the news separately from the other server and integrates it into the page itself. (This means that it will only work if Javascript is supported and enabled.)

First, one note: it's also possible to do this via programs like "cron" and "wget" which automate a regular download of a news file. This is not for the faint of heart, though -- only people who already know what "cron" and "wget" are should try this.

Here, then, are the instructions for the JavaScript method.

1) Get the News Categories addon.

2) Edit ndisplay.pl. (You will have to remove the ! from <Manual!Edit> if you haven't already.) At the beginning (or, if you know Perl, at any other valid point) insert the following:

sub DoJSNews {
# Create a JavaScript news file suitable for inclusion from another site
&DoNewsHTML;
# If you'd prefer to use headlines, change the previous
# line to &DoHeadlineHTML;
$newshtml =~ s/\'/\\'/g; # escape ' as required by javascript
$newshtml =~ s/[\n\r]//g; # remove line feeds
$newshtml = "document.write('$newshtml');";
}

3) Via the News Categories addon, create a new profile. Configure it appropriately (which categories you want to include news from, how much news you want to include). Set the "Generate news using ndisplay.pl subroutine" option to DoJSNews and then set the "Create <a name> tags with news" option (the last one) to No.

4) Build news. You will now find a new text file in your HTML files directory called profilename.txt where profilename is the name of the profile you just created. Find the URL (example: <a href="http://yoursite.com/news/othersitenews.txt">http://yoursite.com/news/othersitenews.txt</a>) to this file.

5) Add the following to the HTML file that you want the news to be included in. (This file should be on another server; use the standard SSI method for files on the same server.)

<script src="http://yoursite.com/news/othersitenews.txt"></script>
<noscript>To see the latest news, you need a browser
that supports JavaScript.</noscript>

Replace http://yoursite.com/news/othersitenews.txt in the above with the URL you found in step 4. You can also edit the text between <noscript> and </noscript> -- this is what is displayed to users whose browsers don't support JavaScript or who have disabled JavaScript.

 

Back to NewsPro FAQ