w3easyNews Manual

News Script

w3easyNews Manual

Postby admin » 07.12.2011 14:36

SCRIPT:
w3easyNews
(C) 2011 Joachim Haack, http://w3easy.org

LICENSE
GNU General Public License, Version 3

REQUIREMENTS
PHP 5 (maybe also PHP 4 will do), NO DATABASE required.

EXAMPLES
News Item:
Code: Select all
<h4>News Title</h4>
<p>News Text</p>

Image - Link - Line Break:
Code: Select all
<img src='' alt='' title=''>
<a href=''>link title</a>
<br> or <br />

DESCRIPTION
With the w3easyNews script you can easily write, store and publish news online. The script will create a directory, that contains the news files. Furthermore the script will create a source file ('source.inc.txt'), where the news are written and stored, an output file ('archive.inc.txt') to publish and display the news dynamically and last but not least 2 output files to alternatively display the news resp. the archive statically.

The script provides the possibility to display as a small news box with few news items as a news archive with many or even all news items dynamically using the same archive file. Furthermore you have the possibility to specify the total number of news that shall be displayed and also the max number of news that shall be displayed per page, i.e. the script will set up and dynamically divide the archive in as many pages as needed to display the news items you want to have displayed (see examples below).

For it is not possible to put more than 1 dynamic newsbox resp. dynamic archive to the same page (without using tricks...), there is still the possibility to display the news resp. the archive in static mode using 2 static output files - 1 output file for the few news items and 1 output file for the news archive. So if you need f.e. a newsbox plus a news archive at the same page, I'd recommend to display the news box using the static output file but to display the archive using the dynamic output mode.

Note: The script comes without a wysiwyg editor. But with the help of the example codes at the top of the help file it shouldn't be asked to much of you to set up a news item and also an image or a link using the respective html tags...

INSTRUCTIONS
Installation
First unpack and then upload the script folder to your webspace. Make sure that only you have access to the scriptfolder (I'd recommend htaccess directory protection using our w3easyProtect script).
Make sure that you have permission to edit the config file (depending on your server settings chmod file to 0666, 0664 or 0644 if necessary.)

Settings (creating news)
Open the index.php and submit the form with checked 'show config' radio button. Have a look at the config settings:

Code: Select all
$path_to_root   = "../../../"; // path to root (the site link on top)
$path_to_admin  = "./"; // path to admin (only used within w3easyCMS)
$charset        = "UTF-8"; // charset "UTF-8" or "ISO-8859-1" or ?
$separator      = "#####"; // separator between the news items
$news_dir       = "na-data"; // path to news folder (no trailing slash)

You may have your news folder anywhere on your site, maybe in your content folder. But make sure that you have permission to create the news folder (if it does not yet exists) and to create and edit files within the folder. Depending on your server settings chmod folder to 0777, 0775 or 0755.

Settings (displaying news dynamically)
The following display settings can be overwritten individually on the page(s) where the news shall be displayed (see examples below). But you should define general settings here in the config file and overwrite them in the inclusion term if needed. (Note: When overwriting them in the respective files, you have to do it without the '_cfg' at the end of the settings term).

Code: Select all
$arch_title_cfg   = "News"; // default archive resp. newsbox title
$arch_t_tag_cfg   = "h1"; // default archive  resp. newsbox title tag
$item_A_cfg       = "1"; // default number of 1. item to be displayed
$items_N_cfg      = "1000"; // default total number of displayed items
$items_page_cfg   = "5"; // default max number of items per page
$order_Arch_cfg   = "fifo"; // "fifo" (default) or "lifo"
// ('fifo' = first in - first out // 'lifo' = last in - first out)
'fifo' = first in - first out # 'lifo' = last in - first out (corrected)

The following display settings specifying the look of the links to the dynamically created archive pages are to be defined only in the config file:

Code: Select all
$link_term      = ""; // "", "page", "Seite", "xyz"
$link_title     = ""; // "", "More", "Mehr", "xyz"
$link_title_nl  = ""; // "", "yes" // link title new line?

Now it's high time to include the dynamic archive functions. But why do we have to do it in the config???
Hmmm.... Ok, in some cases, f.e. if the script is used in a cms, it might be useful to put the functions in the main function file, so we added the possibility to prevent the including of the functions to the script.
But regularly we surely will include the functions like this:

Code: Select all
$w3eArch_func   = "yes"; // include functions ?

(Btw: If you don't include the functions to the script file, but add them to your main function file, you should be able to display more than 1 dynamic newsbox/archive on the same page...).

Settings (displaying news statically)
The settings of the static output have to be specified in the config file:

Code: Select all
$title_newsbox  = "News"; // leave blank if no title
$title_archive  = "News Archive"; // leave blank if no title
$title_tag      = "h3"; // "h3" // leave blank if no title
$items_box      =  3; // number of items in the news box
$items_arch_A   =  1; // number of first item in the news archive
$items_arch_Z   =  "all"; // "1,2,3..." or "all" // number of last item
$order_News     = ""; // "fifo" or "lifo"

Btw: Don't forget to save your settings!

USAGE
Creating or adding news
Open the source file by checking the 'show source' button and submitting the form. If the news directory specified in the settings not yet exists, the w3easyNews script will create. If the source file not yet exists, the script will create. Write your news. You may use the examples at the top of the help file to get the html tags quick and correct. Separate each news item from the following news item with the separator string you specified in the config (but do not put a separator string above the first news item nor below the last news item of the source file!). Save your news by submitting the form with checked 'edit source' radio button.
Your news are stored now, but not yet published.
To publish the news, submit the form with a checked 'publish' radio button. Note that you can only publish, if the source is displayed in the text area. If the output files not yet exist, the w3easyNews script will create them. Otherwise it will overwrite them.

Displaying a newsbox and/or a news archive dynamically
Important: You may not have more than 1 dynamic newsbox or dynamic archive on the same page! If you need more than 1 newsbox or archive, you have to include static output files (see below).

To include a dynamic news box or news archive on a page of your site, you first have to specify the path to the news archive and also the path to the w3easyNews script folder like this:

Code: Select all
$archive     = "your/path/to/archive.inc.txt";
$pt_w3eArch  = "your/path/to/w3easyNews/";

Then you have to specify the individual display settings (elsewise the script will use the default settings in the config file) :

Code: Select all
$arch_title  = "Archive";
$arch_t_tag  = "h1";
$item_A      = "1";
$items_N     = "1000";
$items_page  = "8";
$order_Arch  = "fifo";

Now you have to include the file 'w3eArch.inc.php' within the script folder. To do this you can use the path to the script folder specified above and then add the file name like this:

Code: Select all
include ($pt_w3eArch."w3eArch.inc.php");

To display the newsbox resp. the archive, finally insert the following line where you want the newsbox or archive to be displayed:

Code: Select all
echo $w3easyArchive;


Examples (dynamic display)
1. You want to have a newsbox on your startpage or maybe on all of your pages displaying 5 news items:

Code: Select all
$archive     = "your/path/to/archive.inc.txt";
$pt_w3eArch  = "your/path/to/w3easyNews/";

$arch_title  = "News Box";
$arch_t_tag  = "h3";
$item_A      = "1";
$items_N     = "5";
$items_page  = "5";
$order_Arch  = "lifo";

include ($pt_w3eArch."w3eArch.inc.php");
echo $w3easyArchive;

2. You want to have a page containing your news archive displaying 40 news items beginning with the 6. item, but not more than 10 news items per page:

Code: Select all
$archive     = "your/path/to/archive.inc.txt";
$pt_w3eArch  = "your/path/to/w3easyNews/";

$arch_title  = "Archive";
$arch_t_tag  = "h1";
$item_A      = "6";
$items_N     = "45";
$items_page  = "10";
$order_Arch  = "lifo";

include ($pt_w3eArch."w3eArch.inc.php");
echo $w3easyArchive;

Displaying a newsbox and/or a news archive statically
To display a newsbox or the archive statically, you only have to include the resp. files where you want them to appear.

Examples (static display)

Code: Select all
Newsbox:
$nbox = "your/path/to/newsbox.inc.txt";
if (file_exists($nbox)){include ($nbox);}
else {echo "newsbox not found";}

Archive:
$arch = "your/path/to/archive-box.inc.txt";
if (file_exists($arch)){include ($arch);}
else {echo "archive box not found";}

That's it.
Have fun and take it w3easy... ;)
User avatar
admin
Administrator
 
Posts: 21
Joined: 17.03.2011 17:36

Return to w3easyNews

Who is online

Users browsing this forum: No registered users and 1 guest

cron