Jump to content

[SOLVED] Template


unidox

Recommended Posts

I have this code that updates the php site depending on whats in the sql.

 

$tpl = file_get_contents("templates/" . $name . "/index.php");

$index = file_get_contents("pages/news.inc.php");
$site = get_tag("url", "templates/stk/", $tpl);
$site = get_tag("content", $index, $site);
file_put_contents("templates/" . $name . "/index.php", $site);

include("templates/" . $name . "/index.php");

 

The only problem is, how do I make it so instead of updating the file, I can just print out the data. I tried using echo $site, but the php gets blocked out for some reason.

 

Here is news.inc.php:

<div id="center_head">
<div id="center_head_txt">News</div>
</div>
<?php
$q2 = mysql_query("SELECT * FROM `pcp_news`") or die(mysql_error());

$limit = TABLE_LIMIT;
if (!isset($_GET['g']) || (!is_numeric($_GET['g']))) {
$group = 1;
} else {
$group = $_GET['g'];
}
$start = (($group * $limit) - $limit);

$q = mysql_query("SELECT * FROM `pcp_news` ORDER BY `date` DESC LIMIT $start, $limit") or die(mysql_error());

$rows = mysql_num_rows($q2);
$total_pages = ceil($rows / $limit);

if (mysql_num_rows($q2) == 0) {
echo "There are not any news posts!";
} else {
while ($r = mysql_fetch_array($q)) {
?>
<div id="center_title">
<div id="center_title_txt">
	<div id="center_title_txt_title">Title: <?=$r['topic']?></div>
	<div id="center_title_txt_date">Posted By: <?=$r['author']?> on <?=$r['date']?></div>
</div>
</div>
<div id="center_body">
<div id="center_body_txt"><?=$r['message']?></div>
</div>

<?
}
}
?>

 

and the template has delimiters like {content} stuff like that.

Link to comment
https://forums.phpfreaks.com/topic/117095-solved-template/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.