This website can use cookies to improve the user experience

This website can use cookies to improve the user experience and to provide certain services and functions to users. Cookies contain small amounts of information (such as login information and user preferences) and will be stored on your device.

Enable All Cookies Privacy Policy

Using Includes (SSI/PHP)


avatar
mark99 9
From: -
Using Includes (SSI/PHP)

More questions, I know you love them Smiling Face .

On my front page I also have a number of includes, all using SSI and most including .txt files (example below includes output from a PHP) from forums and other output. Here's one example I use:

<!--#include virtual="../../rss/feed2html.php"-->

 http://www.ispreview.co.uk/rss/feed2html.php

There's also this for the easier .txt file include:

<!--#include virtual="../../review/latest.txt"-->

 http://www.ispreview.co.uk/review/latest.txt

Now I've tried adjusting the ../../ bit to the direct path depth and it works from my CT dir in a test.shtml file but not from inside CT. I've also tried a php include, although this doesn't work either and I can't use that for the RSS include anyway because that's from another .php script. What's the best solution here?

Notice

This topic is archived. New comments cannot be posted and votes cannot be cast.

Responses to this topic


1 Re: Using Includes (SSI/PHP)
avatar
Editor
0
From: -
Try to replace include() with virtual():

virtual("rss/feed2html.php");


virtual() seems to have the same functionality that SSI offers, but it will not work on all servers.
1 Re: Using Includes (SSI/PHP)
avatar
OP 9
From: -
That works for flat text files, but the PHP RSS output and my own survey system (that I intend to keep because it's well indexed and recognised) generate their content semi-dynamically. So how would I go about showing this in the style?

 http://www.ispreview.co.uk/cgi-bin/polls/ssi.cgi?08hours

Obviously this would normally be called with SSI.
1 Re: Using Includes (SSI/PHP)
avatar
Editor
0
From: -
You can't use server side includes in the templates; instead you need to do it with PHP.

Here an example to include the output of an external PHP script:

PHP Part:

ob_start();

include("rss/feed2html.php");
$feed2html = ob_get_contents();
ob_end_clean();


HTML Part:

{$feed2html}


To include a text file:

PHP Part:

$tfile = fopen("review/latest.txt","r");

$latest_reviews = fgets($tfile, 4096);
fclose($tfile);


HTML Part:

{$latest_reviews}

Notice

This topic is archived. New comments cannot be posted and votes cannot be cast.