News Script
News content management system

This simple to use content management system will allow you to show the headlines and summary on any webpage and link to the full article, all in the same style as your website. You can add delete and edit news with ease using the administrator suite. The advanced version can split the headlines over many page and has a search engine, scrolling news ticker and newsletter mode.  The XTra version now also features sorting of news and an RSS feed generator. (CGI/Perl Unix)
Current version : 2/May/2006

Overview of the script
Convert your current database
Set-up the script
Create your database
Five quick ways to protect your database
Create the template for the headlines
Create the template for the news 
Inserting the headlines into a webpage
Adding a search engine
[Xtra version only]
Adding a news ticker to another webpage [Xtra version only]
Using the News Letter mode [Xtra version only]
How to use the administrator suite


Overview of the script

News Script
:
The user visits a webpage and the news headlines and summary are automatically included. By clicking on a headline they are taken to the full story. The style of the headlines and the news page is managed by a simple template. Using the administration suite the webmaster can add, edit and delete pages from the database.

News Script Xtra:
The user visits a webpage and the news headlines and summary are automatically included. By clicking on a headline they are taken to the full story. The style of the headlines and the news page is managed by a simple template. Using the administration suite the webmaster can add, edit and delete pages from the database. With the Xtra version a user can search the database for news items. You can also display the news in a newsletter mode and news ticker.  You can order the news by any database field you like (e.g. the headline), except the date field.  You can generate an RSS feed which will be automatically updated when you make changes.

Files you will need:
News Script script (download from this website)
Dbconvert script (in same zip - only necessary when upgrading)
Template for the headlines (instructions on this page)
Template for the web pages (instructions on this page)

Things you have to do:
Follow the instructions below
Download the News Script script and make a few changes
When you have an existing database, run the database upgrade script
Create a link in your webpage
Create a 'template' in your own style for the news
Create a 'template' in your own style for the headlines
Upload the script and webpages
Use the administration suite to add, edit or delete news.

Site Security

Minimum Requirements:
Your own website with FTP access
Permission to run CGI scripts on your server
UNIX web hosting with Perl 5.006001 or greater

Features Basic Xtra
For commercial and private use YES YES
Can be used on as many websites as I build YES YES
No adverts or links in the script YES YES
Instant download YES YES
Show headlines and news on any webpage YES YES
Add, edit and delete news YES YES
Show the headlines in any style you choose YES YES
Show the pages in any style you choose YES YES
Include images in both the templates YES x1 YES x2
Upload images with the pages YES YES
Password Protection YES YES
Split the headlines over many pages - YES
Automatic database creation by script YES YES
Search engine for the database - YES
News Ticker for any webpage - YES
News Letter mode - YES
Use HTML code for e.g. table in the text field - YES
Order the headlines by any field (except date) - YES
Generate an RSS feed for your site - YES
Specify the target window/frame to open news items - YES

Back to Top

Convert your current Database

You only need to perform this step if :

  • You are currently using a Newsscript version dated before April 2005.
  • You want to use your current database with the new version of the script.

Others can skip to "Set-up the script".

Edit the dbconvert.pl script :

Give a name for the field that will hold a unique id for each news item :
$IDField = 'ID';
Give a start value for this unique id field :
$startID = 1;
Tell the script where to find your current database :
$databasefile = 'news.txt';"

Save the script in unix format (see FAQ) and upload it to your server.  Chmod to 755 or 777 and run it after making a backup of your current database.  You run the script by just typing the URL to it in your browser address bar, like : 
http://www.your-url.co.uk/cgi-bin/dbconvert.pl
If all went well, you will see :

"Finished ! You can now use it with this version of Newsscript."

Set-up the script

News Script
Basic

Check your path to perl
#!/usr/bin/perl

Full URL of this script
my $script_name = 'http://www.your-url.co.uk/cgi-bin/newsscript.pl';

Change the Full Path (not URL) of your database,
this will be created when you first add a record.
my $databasefile = "/home/vhosts/cgi-bin/news.txt"; 

Change the Full Path (not URL) of the directory the images are stored in
my $image_dir = "/home/vhosts/cgi-bin/images/";

Change the URL (not Path) of the directory the images are stored in,
without the last trailing slash /
my $image_url = "http://www.your-url.co.uk/cgi-bin/images";

The Full Path (not URL) of the headlines template
my $html_template = "/home/vhosts/cgi-bin/headlines.htm";

The Full Path (not URL) of the news web page template
my $record_template = "/home/vhosts/cgi-bin/news.htm";

Choose a name for the field that Newsscript will use to identify each news item.  If you used dbconvert.pl to convert your database, then use the same fieldname you used there.
my $idField = "ID";

You can change the 'admin' mode name to anything you like, so mode=admin can be any 'word' that you choose it to be.  It is wise not to choose 'admin' for this.
my $admin_mode = 'admin';

To use the select image option use 1 to turn it off use 0
my $select_image = 1;

Select the value of the Horizontal and Vertical spacing round the images.
my $hspace = 9;
my $vspace = 2;

Select a username and password or leave blank.
my $Username = 'name';
my $Password = 'password';

Display the news items first or last
my $news_up = 1;

Upload and CHMOD 755, or 777 if not public.

Back to Top


News Script Xtra

Check your path to perl
#!/usr/bin/perl

Full URL of this script
my $script_name = 'http://www.your-url.co.uk/cgi-bin/newsscript.pl';

Change the Full Path (not URL) of your database,
this will be created when you first add a record.
my $databasefile = "/home/vhosts/cgi-bin/news.txt";

Choose a field name that Newsscript will use internally to uniquely identify news items.  If you used dbconvert.pl to convert your database, then use the same fieldname you used there.
my $idField = "ID"; 

Change the Full Path (not URL) of the directory the images are stored in
my $image_dir = "/home/vhosts/cgi-bin/images/";

Change the URL (not Path) of the directory the images are stored in,
without the last trailing slash /
my $image_url = "http://www.your-url.co.uk/cgi-bin/images";

The Full Path (not URL) of the headlines template
my $html_template = "/home/vhosts/cgi-bin/headlines.htm";

The Full Path (not URL) of the news web page template
my $record_template = "/home/vhosts/cgi-bin/news.htm

You can change the 'admin' mode name to anything you like, so mode=admin can be any 'word' that you choose it to be.
my $admin_mode = 'admin';

To use the select image option use 1 to turn it off use 0
my $select_image = 1;

Select the value of the Horizontal and Vertical spacing round the images.
my $hspace = 9;
my $vspace = 2;

Select a username and password or leave blank.
my $Username = 'name';
my $Password = 'password';

Message to display if no news is found with a search.
my $not_found = '<b>No results found</b><br><br><br>';

Display the news items first or last
my $news_up = 1;

Target to open full news item from the headlines page (can be _new, _self, ...).
my $newstarget = "_self";

Text for 'previous' button
my $textPrevious = "Previous";

Tex for 'next' button
my $textNext = "Next";

Number of pages in the range at any time
my $pageSelectorRange = 10;

Number of headlines per page
my $records_per_page = 5;

Number of headlines in the scrolling news ticker, use 0 for all
my $Number_of_headlines_to_scroll = 5;

Speed of the news ticker
my $speed = 4;

Background colour of the news ticker
my $bgcolor = "#eeeeee";

Number of news items in the newsletter mode, use 0 for all news
my $Number_of_news = 10;

Seperator between headlines and news in newsletter mode.
my $head_news_separator = "<hr noshade color=#000000><br>";

Seperator between news items in newsletter mode.
my $new_news_separator = "<hr noshade color=#000000><br>";

You can request the script to 'Highlight' the results of a search with a different colours. Use 1 to switch this feature on a 0 to switch it off. This will work with the search=value but not with fieldname=value. You can not use a field that is searched in HTML code in your website with this feature.

my $highLighting = 1;
my @highLightColors = ("#FFFF00", "#FF0000", "#00FFFF", "#00FF00", "#C0C0C0");

If you want to paste HTML code (like tables, etc...) into your text field, you can use these tags to tell Newsscript that it should not add line breaks to the code.  You can change these tags to whatever you like.
my $start_pure_html = '<purehtml>';
my $end_pure_html = '</purehtml>';
Note : as a consequence of how HTML is, the script cannot allow html breaks in between those tags.  Best thing to do is to use tables there to structure your content.

You can have Newsscript order the headlines by a certain field.  Tell newsscript which field you want it to order by :
my $order_by = "headline";

Tell newsscript the kind of ordering (alphabetical/numerical, ascending, descending).  Valid ordering options are : "123", "321", "abc" and "cba" :
my $order = "abc";

Newsscript can create and automatically update an RSS feed for your site :
my $usefeeds = 1;
  You can set this to 0 if you do not want to use an RSS feed.
my $feed = "feed.rss";
  File to which the feed should be saved.
my $feed_title = "NewsScript News Flash";
my $feed_description = "Stay tuned on what happens on your-url.co.uk";
my $reverse_feed = 1;
  If set to 0, oldest records will appear first in the RSS feed, if set to 1 the most recent records will appear first.

Upload and CHMOD 755, or 777 if not public.

Back to Top


Create your database

When you first add a record the script will create the database for you. You don't need to create one.

News Script is designed for a small to medium website and can manage around 100 records or 1MB to run smoothly on most servers.

NOTE: Please do not use field names in your database used in the script or template, including, name, method, action, page, record, header, random, display, search, order_by, order, mode & headlines.

Back to Top


Five quick ways to protect your database

1) Download the current version of the script
2) Use the username and password feature
3) Re-name the script from newsscript.pl to anything.pl
4) Re-name the database from news.txt to anthing.txt
5) Re-name the mode=admin to mode=anything

Back to Top


Create the template for the headlines

This will display the headlines in the way you wish to see them. Use the sample template first to ensure everything is working okay, then customise the template to your needs. Everything inside the template brackets is repeated for each record (including any HTML code), everything outside the template brackets is displayed just once.

Sample code for the headlines template. You do not need to use all the features, for example you could just display the headlines without the page summary. The [[headline]] will automatically link to the full story as will the [[more]]. The short text will display your summary of the webpage. By adding [[page_selector]] (Xtra version only) anywhere on the page (outside the template brackets) you can link to the rest of the headlines. The [[date]] is just a text field and a option to add a date in the format you wish to type it.



A sample template is enclosed with your download.

Back to Top


Create the template for the news

This will display the news story or webpage in the way you wish to see them. Use the sample template first to ensure everything is working okay, then customise the template to your needs.

Sample code for the news template. The code around the <template> brackets is your normal HTML page. Inside the <template> bracket is data for that page. You can display the information in any format you wish. Change the font the location of the image, the size of the headline, add a menu images, almost anything you would do with an HTML page, keep it simple or make it as creative as you wish. The script will insert the data where you tell it to.



A sample template is enclosed with your download. With News Script Xtra you add a second image using [[image2]] ideal for a thumbnail image 

Back to Top


Inserting the headlines into a webpage

You can display headlines in two ways, by using a link or a virtual include on another webpage on your site.

To have a virtual include on a webpage you must use Server Side Includes. To do this rename your htm or html page to shtml.

Then add <!--#include virtual="/cgi-bin/newsscript.pl"--> at the location you wish to see the headlines. Use the features below in the same way to choose the way the headlines are displayed.

/cgi-bin/newsscript.pl or
<!--#include virtual="/cgi-bin/newsscript.pl"-->
This will display the number of headlines selected in the script in the format of your headlines template. Ideal as a link from the main page.

/cgi-bin/newsscript.pl?headlines=3 or
<!--#include virtual="/cgi-bin/newsscript.pl?headlines=3"-->
This will display a requested number of headlines in the format of the headlines template. Ideal as a second news page with less headlines.

/cgi-bin/newsscript.pl?mode=shtml or
<!--#include virtual="/cgi-bin/newsscript.pl?mode=shtml"-->
This will display all the headlines, ignoring all the code outside the template brackets of the headlines template. Ideal for inserting all the headlines in another webpage on your site where you don't want to use the full headlines template.

/cgi-bin/newsscript.pl?headlines=3&mode=shtml or
<!--#include virtual="/cgi-bin/newsscript.pl?headlines=3&mode=shtml"-->
This will display a requested number of headlines, ignoring all the code outside the template brackets of the headlines template. Ideal for inserting a few headlines in another webpage. Ideal for inserting just a few headlines in another webpage on your site where you don't want to use the full headlines template.

Back to Top


Adding a search engine [Xtra version only]

With News Script Xtra you can add a search engine to allow users to search all the database or just one field. You can do this with links or a search box in a form.

Basic search of all the database:

Search:



Add the option for an exact phrase match only:

Search: Exact:



Give the option of the field to search:

Search:
Field:
All Headlines  Summary Main Text

    

Add both the field to search and the option of an exact match:

Search: Exact:
Field:
All Headlines  Summary Main Text



Add the option for the user to choose hoe many results per page:

Search:  
Field:
All Headlines  Summary Main Text Exact Match:



Back to Top

Adding a news ticker to another webpage [Xtra version only]

You can add a fixed number of news headlines to any page in your website using a SSI (Server side include). To do this name your page .shtml rather than .htm or .html and where you want the ticker to be included add the code below:

<!--#include virtual="/cgi-bin/newsscript.pl?mode=scrollingnews"-->

You can change the font using a style sheet or adding the font details before the SSI code.

Latest News:

Back to Top


Using the News Letter mode [ Xtra version only]

You can display all the news headlines and the full story or a fixed number as a News Letter in any page in your website using a SSI (Server side include). To do this name your page .shtml rather than .htm or .html and where you want the ticker to be included add the code below:

<!--#include virtual="/cgi-bin/newsscript.pl?mode=newsletter"-->

Back to Top


How to use the administrator suite

You can now edit, delete and add records with the administrator suite. Just type the URL in your browser of the administrator site:

/cgi-bin/newsscript.pl?mode=admin

If you have selected to have a username and password you will be asked for it at this point.

Do not use your browsers 'back' button when in the administrator suite. Now you will see the main page that lists all the pages in your system, you can delete, edit or view a record in the list using the menu on the left. Or add a new record from the menu at the top of the page.

To help navigate the text fields for Date and Headline are displayed. Once using the administrator suite you will see it is very simple and needs no instructions to use.

Back to Top

 
 

home | rate the scripts | community support forum | www.ezscripting.com