
Its GPLv3 btw.
When im finished designing my site, im going to release more things like these...Some are going to be commercial, some open-source.
If you need documentation as to how to use it, PM me.
please show me how to use template engine. Thanksimkingdavid wrote:Alright, turns out I was actually the one that was missing something utterly simple, not you (assuming you were using the file I provided a few posts back, which I have now fixed, btw). I had forgotten to remove the second check for if(!defined('IN_PHPBB')) { exit; }, so it was exiting the script. Took me half an hour to realize that too.
Anyway, I set up an example here, which you can download here (zip).
All it does is outputonto the page, but I have explained how to use each of the functions in the script. For info on how to use other template functions, either ask here, check the tutorial in the wiki that I posted in my previous post, or dig through phpBB itself.Hello world
The engine is quite powerful and has pretty much all of the functions you'll need for your site's template and it's very easy to use once you get used to it. BTW, I tried testing out the cache system and it caused blank white pages for me, and when I removed the cache folder everything worked again. If you get it working, great and let me know how. But otherwise, I guess just don't make a folder named cache in your site's root.
Anyway, I hope this helps a few people.
Code: Select all
<?
error_reporting(E_ALL);
require_once '../include/common.inc.php';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Love Wall <?=$navtitle?> <?=$bbname?> <?=$seotitle?></title>
<style><!--@import url(images/style.css);--></style>
</head>
<body scroll=yes>
<div id="menu" >
<a href="../" target="_blank">
<img src="images/01.gif" width="27" height="17" /></a>
<a href="index.php">Home</a> <img src="images/02.gif" width="16" height="16" /> <a href = "add.php" > Gửi ước nguyện </a> <img src="images/03.gif" width="16" height="16" /> <a href="list.php"> Xem danh sách </a> <img src = "images/04.gif" width = "27" height = "18" /> <a href="http://hagiangpro.com" target="_blank"> Đọc báo </a> <img src = "images/05.gif "width ="15"height ="12"/> <a href="../index.php"> Quay lại diễn đàn </a> <img src ="images/06.gif"width ="16" height = "16" /> <a href="http://hagiangpro.com/"> Tin tức </a> </div>
<div id="main" style="width:900px;position:relative; height:500px">
<div style="display:none;" id="aspk" onclick="Hide();"></div>
<script type="text/javascript" src="inc/index.js"></script>
<?php
$result=mysql_query("select * from cdb_qqlove order by id DESC");
$num=mysql_numrows($result);
for ($i=0;$i<$num;$i++) {
$id=mysql_result($result,$i,"id");
$class=mysql_result($result,$i,"class");
$images=mysql_result($result,$i,"images");
$head=mysql_result($result,$i,"head");
$sign=mysql_result($result,$i,"sign");
$lr=mysql_result($result,$i,"lr");
$date=mysql_result($result,$i,"date");
$cs=mysql_result($result,$i,"cs");
$top =rand(0,314);
$left=rand(0,660)
?>
<div id="Layer<?=$id?>" class="Face<?=$class?>" style="top:<?=$top?>px;left:<?=$left?>px;z-index:<?=$id?>" onMouseDown="Move(this,event)" onDblClick="Show(<?=$id?>)">
<p class="Num">Lời ước số:<?=$id?><img src="images/close.gif" alt="Đóng" onClick="Close(<?=$id?>)" /></p><p class="Detail"><img alt="" src="images/icon<?=$images?>.gif" /><span class="Head"><?=$head?></span><br /><?=$lr?></p>
<table class="Sign" border="0" cellpadding="0" cellspacing="0">
<tr>
<td><div align="left"><a href="zf.php?id=<?=$id?>" title="Ấn để chúc cho lời ước thành sự thật">Đã được chúc: <?=$cs?> lần</a></div></td>
<td><div align="right"><?=$sign?></div></td>
</tr>
</table><p class="Date"><?=$date?></p></div>
<?php
}
?>
</div>
<div id="footer">
<div class="footimg"></div><div class="bottom"><a href="index.php" title="Love Wall">Home</a> -
<a href="add.php" title="Note">Ước nguyện</a> -
Powered by N</div></div>
</body></html>
<?
if(isset($_GET['id'])) {
echo "<script type=\"text/javascript\">Show(".$_GET['id'].");</script>";
}else {
}
?>
Code: Select all
<?php
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
//start
$result=mysql_query("select * from phpbb_love order by id DESC");
$num=mysql_numrows($result);
for ($i=0;$i<$num;$i++) {
$id=mysql_result($result,$i,"id");
$class=mysql_result($result,$i,"class");
$images=mysql_result($result,$i,"images");
$head=mysql_result($result,$i,"head");
$sign=mysql_result($result,$i,"sign");
$lr=mysql_result($result,$i,"lr");
$date=mysql_result($result,$i,"date");
$cs=mysql_result($result,$i,"cs");
$top =rand(0,314);
$left=rand(0,660);
}
if(isset($_GET['id'])) {
echo "<script type=\"text/javascript\">Show(".$_GET['id'].");</script>";
}else {
}
page_header('Love Wall');
$template->assign_vars(array(
'ID' => $id,
'CLASS' => $class,
'TOP' => $top,
'LEFT' => $left,
'IMAGES'=> $images,
'HEAD' => $head,
'LR' => $lr,
'SIGN' => $sign,
'DATE' => $date,
'CS' => $cs,
));
$template->set_filenames(array(
'body' => 'love/index_body.html')
);
page_footer();
?>
Code: Select all
<!-- INCLUDE love/love_header.html -->
<div id="menu" >
<a href="../" target="_blank"><img src="{T_THEME_PATH}/love/images/01.gif" width="27" height="17" /></a>
<a href="index.php">Home</a> <img src="{T_THEME_PATH}/love/images/02.gif" width="16" height="16" />
<a href = "add.php" > Gửi ước nguyện </a> <img src="{T_THEME_PATH}/love/images/03.gif" width="16" height="16" />
<a href="list.php"> Xem danh sách </a> <img src = "{T_THEME_PATH}/love/images/04.gif" width = "27" height = "18" />
<a href="http://hagiangpro.com" target="_blank"> Đọc báo </a> <img src = "{T_THEME_PATH}/love/images/05.gif" width ="15"height ="12"/>
<a href="../index.php"> Quay lại diễn đàn </a> <img src ="{T_THEME_PATH}/love/images/06.gif"width ="16" height = "16" />
<a href="http://hagiangpro.com/"> Tin tức </a>
</div>
<div id="main" style="width:900px;position:relative; height:500px">
<div style="display:none;" id="aspk" onclick="Hide();"></div>
<script type="text/javascript" src="{T_THEME_PATH}/love/inc/index.js"></script>
<div id="Layer{ID}" class="Face{CLASS}" style="top:{TOP}px;left:{LEFT}px;z-index:{ID}" onMouseDown="Move(this,event)" onDblClick="Show({ID})">
<p class="Num">Lời ước số:{ID}<img src="{T_THEME_PATH}/love/images/close.gif" alt="Đóng" onClick="Close({ID})" /></p>
<p class="Detail"><img alt="" src="{T_THEME_PATH}/love/images/icon{IMAGES}.gif" />
<span class="Head">{HEAD}</span>
<br />{LR}
</p>
<table class="Sign" border="0" cellpadding="0" cellspacing="0">
<tr>
<td><div align="left"><a href="zf.php?id={ID}" title="Ấn để chúc cho lời ước thành sự thật">Đã được chúc: {CS} lần</a></div></td>
<td><div align="right">{SIGN}</div></td>
</tr>
</table>
<p class="Date">{DATE}</p>
</div>
</div>
<div id="footer">
<div class="footimg"></div><div class="bottom"><a href="index.php" title="Love Wall">Home</a> -
<a href="add.php" title="Note">Ước nguyện</a> -
Powered by N</div></div>
<!-- INCLUDE love/love_footer.html -->
Code: Select all
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4371: Cannot modify header information - headers already sent by (output started at /love/index.php:1)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4373: Cannot modify header information - headers already sent by (output started at /love/index.php:1)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4374: Cannot modify header information - headers already sent by (output started at /love/index.php:1)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4375: Cannot modify header information - headers already sent by (output started at /love/index.php:1)
imkingdavid wrote:All you have to do is download the files at the link and then include them into your script. Be sure to follow all of the steps in the first post of this topic, starting from the index.php example.
In any case, just saying it doesn't work doesn't make it any easier for us to help us. Can you please provide any errors or explain what exactly isn't working?
(To long to quote)NguyTieuNhan wrote:I have code:....
Code: Select all
<NO SPACE OR ANYTHING BEFORE><?php
// ^
// |
// NO.. this is the reason why getting "[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4375: Cannot modify header information - headers already sent by (output started at /love/index.php:1)". Note the 1 for line 1.
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
/*
Note: mysql_result function is slower than mysql_fetch_row(), mysql_fetch_array(), mysql_fetch_assoc() and mysql_fetch_object().
Note: mysql_result function should not be used together with mysql_fetch_row(), mysql_fetch_array(), mysql_fetch_assoc() or mysql_fetch_object().
~~http://www.w3schools.com/php/func_mysql_result.asp
Whats the point of this part? Your writing over data in ever loop. Are you trying to get the last row?
If so then do this "select ID, CLASS, IMEAGES, HEAD, SIGN, LR, DATE, CS from phpbb_love order by id ASC limit 1"
(revese order and select top one to get the last one)
$result=mysql_query("select * from phpbb_love order by id DESC");
$num=mysql_numrows($result);
for ($i=0;$i < $num;$i++)
{
$id=mysql_result($result,$i,"id");
$class=mysql_result($result,$i,"class");
$images=mysql_result($result,$i,"images");
$head=mysql_result($result,$i,"head");
$sign=mysql_result($result,$i,"sign");
$lr=mysql_result($result,$i,"lr");
$date=mysql_result($result,$i,"date");
$cs=mysql_result($result,$i,"cs");
$top =rand(0,314);
$left=rand(0,660);
}
*/
$result=mysql_query("select ID, CLASS, IMEAGES, HEAD, SIGN, LR, DATE, CS from phpbb_love order by id ASC limit 1");
$num=mysql_numrows($result); // Note: "The number of rows in a result set on success or FALSE on failure."
if($num !=== false && $num == 0) // Identical ( === ): Checks if the left and right values are equal AND identical (same variable type)
{ // and check if there exsit a row.
$row = mysql_fetch_assoc($result); // Get on row per call. Because of the "limit 1" there only one row.
foreach($row as $key => $value)
{
// I can't recall if you cap the ID, CLASS, ETC will return as cap or not. I take it as no
// So I take the $key and force it to be uppercase. I don't know how much time is lose in doing this.
$template->assign_var(strtoupper ($key) ,$value);
}
// Magic number are EVIL!!!!!!!!!!!!
$template->assign_var('TOP', rand(0,314));
$template->assign_var('LEFT', rand(0,660));
}
// I take it that id is number.. //is_numeric
if(isset($_GET['id'])) // I take that id is number
{
// CLEAN ALL DATA - EVEN if its not for mysql. Even in this code. Also have default value or action if $_GET not sent.
$_GET['id'] = trim($_GET['id']); // Remove spaces
$idClean = is_numeric($_GET['id'])? $_GET['id']:0; // 0 is the default action.
// NO! Use the templating engine to add this!
echo "<script type=\"text/javascript\">Show(".$_GET['id'].");</script>";
}
else // What the point of this part? If none best to remove it.
{
}
// BAD IDEA - Have it IN the Template. This method most likly getting html and sending it which is why your having problem
page_header('Love Wall');
$template->set_filenames( array( 'body' => 'love/index_body.html') );
// BAD IDEA - Have it IN the Template. This method most likly getting html and sending it which is why your having problem
page_footer();
?><NO SPACE AFTER>
Code: Select all
$data = "<?php if (!defined('IN_PHPBB')) exit;" . ((strpos($data, '<?php') === 0) ? substr($data, 5) : ' ?>' . $data);
Code: Select all
if (!defined('IN_PHPBB'))
{
exit;
}