combining things (templates and such)
Posted: Sat Feb 14, 2004 11:45 am
I'm trying to seperate all my code into a different file, which calls .txt files for easy inclusion for my site and stuff.
This is really helpful so I can allow people to write reviews/news or w/e then having it include it on the page.
index.php?id=home would call home.txt
index.php:
<?php
include("incs/pagevars.php");
$id = $_GET['id'];
$page = getpage($id);
echo $page;
?>
pagevars.php:
As you can see i basically just stopped coding, because I have a few questions..
I have a counter script i made, that I can include, then call the function getcount(); to display the hits so far and stuff, which is simple, but what about poll scripts and the like, which just have you include a file (say poll.php)?
If i just included that file in my function, it wouldnt get printed out, because it wouldnt be part of the $page variable..
So would I have to copy all the code from poll.php and put it in my getrightcol() function or what? cause thats the only way I can think this would work..
This is really helpful so I can allow people to write reviews/news or w/e then having it include it on the page.
index.php?id=home would call home.txt
index.php:
<?php
include("incs/pagevars.php");
$id = $_GET['id'];
$page = getpage($id);
echo $page;
?>
pagevars.php:
Code: Select all
<?php
function getpage($id){
$filename = $id . ".txt";
$handle = fopen($filename, "r");
$contents = fread($handle, filesize($filename));
fclose($handle);
$leftcol = getleftcol();
$rightcol = getrightcol();
$page = <<<EOT
<html>
<head>
<title>LanP245 - $id</title>
<link rel="stylesheet" type="text/css" href="incs/mainstyle.css" />
<script language="javascript" src="incs/mainfunctions.js"></script>
</head>
<body>
<div align="center">
<table width="770" height="100%" cellspacing="0" cellpadding="0">
<tr>
<td colspan="3"><img src="imgs/header.jpg"></td>
</tr>
<tr>
<td width="120">$leftcol</td>
<td width="*">$contents</td>
<td width="120">$rightcol</td>
</tr>
</table>
</div>
</body>
</html>
EOT;
return $page;
}
function getleftcol(){
$filename = "
$handle = fopen($filename, "r");
$contents = fread($handle, filesize($filename));
fclose($handle);
}
function getrightcol(){
}
?>As you can see i basically just stopped coding, because I have a few questions..
I have a counter script i made, that I can include, then call the function getcount(); to display the hits so far and stuff, which is simple, but what about poll scripts and the like, which just have you include a file (say poll.php)?
If i just included that file in my function, it wouldnt get printed out, because it wouldnt be part of the $page variable..
So would I have to copy all the code from poll.php and put it in my getrightcol() function or what? cause thats the only way I can think this would work..