Include the Script

The script can be included into an existing website using PHP or SSI (Server Side Includes).

Include with PHP

Step 1

Copy the file include.php to the folder where the file(s) reside you want News Script to include in.

Step 2

Open the file in a text editor and change the path to the script in

define('N2S_ROOT', './');

Replace ./ with the path to the script, i.g. ./news_script/.

Set the include mode.

define('N2S_INCLUDE_MODE', 3);


You have three options:

1 - Only the article list is included. You can use this for a "Latest News" box. No pagination links are shown. The article link goes to the standalone News Script.

2 - Only article list and pagination are shown. The article link goes to the standalone News Script.

3 - Full include of article and article list. In this mode the script uses the template files from the folder /template/include/

Step 3

Add the PHP include statement at the very top of your existing PHP file. It is important that no output is made before the include statement.

include './include.php';

If that produces any errors, try virtual:

virtual './include.php';

In case you have HTML code in your PHP file, it would have to look like this:

<?php include './include.php'; ?>

<html>
  <head>[...]</head>
  <body>[...]</body>
</html>

Step 4

Cut the variable $n2s_output from the new include.php file and paste it in the place in your existing PHP file where you want the News Script content to appear.

echo $n2s_output;

In case you have HTML code in your PHP file, it would have to look like this:

<?php echo $n2s_output; ?>

It is important that you delete the variable $n2s_output from include.php once you have added $n2s_output to your existing web page.

Done

The script should be working now. If not, please check steps 1 - 3.

Note: Since you are including the script into an existing web page, you probably want to strip the HTML frame from the default template file layout.tpl.html. In that case you probably also want to include the script's CSS file into the HTML head:

<link rel="stylesheet" href="/news/template/default/style.css" type="text/css" />