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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.