PDA

View Full Version : Including perl results on pages??.


bnjp
11-20-2004, 07:16 PM
This is a little beyond the norm, but here's what I'm trying to do. I've got a calendar program that will display the current 7 days of events on a page through an SSI call (or I have been using PHP's "virtual" call to do it on a php page. I'm trying to get this to work on ArticleLive but am having a problem.

I've got the events showing but it doesn't show the events in the panel, but puts them at the top of the page, above the page html. It puts a little number "1" where the data should go.

Here's the page: http://northpointeonline.org/articlelive/
the data I'm trying to import is here: http://northpointeonline.org/cgi-bin/calendar/calendar.pl?template=ssi2.html&duration=7d

I created a new panel called "CalendarPanel" and am trying to use that on the DefaultRightColumnPanel.

Here is my Calendar Panel:


/*******************************************\
* *
* Generic ArticleLive Panel Parsing Class *
* *
\*******************************************/

$panelClass = "AL_CALENDAR_PANEL";

CLASS AL_CALENDAR_PANEL
{
var $_htmlFile;

function AL_CALENDAR_PANEL($HTMLFile)
{
$this->_htmlFile = $HTMLFile;
}

function ParsePanel()
{
$htmlPanelData = "";
$parsedPanelData = "";

if(file_exists($this->_htmlFile))
{
if($fp = @fopen($this->_htmlFile, "rb"))
{
while(!feof($fp))
$htmlPanelData .= fgets($fp, 4096);

@fclose($fp);
}
}

// Parse the panel of tokens, etc
$GLOBALS["CalData"] = include ("http://northpointeonline.org/cgi-bin/calendar/calendar.pl?template=ssi2.html&duration=7d");

$parsedPanelData = $GLOBALS["AL_CLASS_TEMPLATE"]->ParseGL($htmlPanelData);
return $parsedPanelData;
}
}





and my DefaultRightColumnPanel code:


/*******************************************\
* *
* Generic ArticleLive Panel Parsing Class *
* *
\*******************************************/

$panelClass = "AL_DEFAULTRIGHTCOLUMN_PANEL";

CLASS AL_DEFAULTRIGHTCOLUMN_PANEL
{
var $_htmlFile;

function AL_DEFAULTRIGHTCOLUMN_PANEL($HTMLFile)
{
$this->_htmlFile = $HTMLFile;
}

function ParsePanel()
{
$parsedPanelData = "";

/*
This template is comprised of up to 5 external panels, which we simply
parse and then return combined:

1. SmallArticleFavouritesPanel1
2. ArticlesToReadPanel1
3. ArticleHistoryPanel1
4. PopularArticlesPanel1
5. PopularAuthorsPanel1
*/

$GLOBALS["imagePath"] = AL_TPL_IMAGE_PATH;

$parsedPanelData .= $GLOBALS["AL_CLASS_TEMPLATE"]->_GetPanelContent("CalendarPanel");
$parsedPanelData .= $GLOBALS["AL_CLASS_TEMPLATE"]->_GetPanelContent("SmallArticleFavouritesPanel1");
$parsedPanelData .= $GLOBALS["AL_CLASS_TEMPLATE"]->_GetPanelContent("ArticlesToReadPanel1");
$parsedPanelData .= $GLOBALS["AL_CLASS_TEMPLATE"]->_GetPanelContent("ArticleHistoryPanel1");
$parsedPanelData .= $GLOBALS["AL_CLASS_TEMPLATE"]->_GetPanelContent("PopularArticlesPanel1");
$parsedPanelData .= $GLOBALS["AL_CLASS_TEMPLATE"]->_GetPanelContent("PopularAuthorsPanel1");

return $parsedPanelData;
}
}




Anybody see what am I doing wrong? or will this work at all? I just figure if I can get it on the page at all, I should be able to get it in the right spot.... :(

bnjp
11-23-2004, 03:07 PM
Anybody got any ideas here? I'll either have to not use my calendar, or not use articlelive. I've got the calendar working on my demo page at http://northpointeonline.org/index2.php which is a regular php page using a PHP 'include' .

It's just frustrating me that I can't get the calendar where I want it on the ArticleLive page since everything else works so nicely.

Chris S
12-06-2004, 11:21 PM
Hi,

You can't 'include' a remote file like that.

You'll need to either use

http://www.php.net/file

like thus:


$content = file($url);
$GLOBALS['calData'] = implode('', $content);


or

http://www.php.net/fopen

like thus:


$fp = fopen($url, 'rb');
$content = '';
while(!feof($fp)) {
$content .= fread($fp, 1024);
}
fclose($fp);
$GLOBALS['calData'] = $content;


neither of my examples include error detection (can't open the page or whatever) - change to your needs.

Anybody got any ideas here? I'll either have to not use my calendar, or not use articlelive. I've got the calendar working on my demo page at http://northpointeonline.org/index2.php which is a regular php page using a PHP 'include' .

It's just frustrating me that I can't get the calendar where I want it on the ArticleLive page since everything else works so nicely.