phpBB Standalone Template Engine

Discussion forum for MOD Writers regarding MOD Development.
Locked
ChaosBringer
Registered User
Posts: 412
Joined: Mon Apr 19, 2004 11:30 pm
Contact:

Re: phpBB Standalone Template Engine

Post by ChaosBringer » Thu Feb 25, 2010 1:56 pm

Take a look at the link i posted and you'll see what it can do :)

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.

01000001 01101100 01101100 00100000 01111001 01101111 01110101 01110010 00100000 01100010 01101001 01101110 01100001 01110010 01111001 00100000 01100001 01110010 01100101 00100000 01100010 01100101 01101100 01101111 01101110 01100111 00100000 01110100 01101111 00100000 01110101 01110011 00100001

NguyTieuNhan
Registered User
Posts: 96
Joined: Fri Nov 21, 2008 12:31 am

Re: phpBB Standalone Template Engine

Post by NguyTieuNhan » Thu Jul 22, 2010 3:41 am

imkingdavid 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 output
Hello world
onto 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.

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. :)
please show me how to use template engine. Thanks

User avatar
imkingdavid
Former Team Member
Posts: 2667
Joined: Sun Jul 26, 2009 7:59 pm
Location: EST
Name: David King

Re: phpBB Standalone Template Engine

Post by imkingdavid » Thu Jul 22, 2010 6:16 am

The wiki is a great resource for such matters. ;)
Don't forget to smile today. :)
Please do NOT contact for support via PM or email.
Remember, the enemy's gate is down.

DreamCrafter
Registered User
Posts: 20
Joined: Thu Sep 09, 2010 10:52 pm
Location: United Kingdom
Name: Daniel Dickson
Contact:

Re: phpBB Standalone Template Engine

Post by DreamCrafter » Sun Nov 07, 2010 8:39 pm

I tried creating this Template Engine but it doesn't work for me. Could someone help me out?

User avatar
tbackoff
Former Team Member
Posts: 7022
Joined: Thu Jun 04, 2009 1:41 am
Location: cheerleading practice
Name: Tabitha Backoff

Re: phpBB Standalone Template Engine

Post by tbackoff » Mon Nov 08, 2010 12:04 am

What exactly didn't work?
Flying is the second best thrill to cheerleaders; being caught is the first.

User avatar
imkingdavid
Former Team Member
Posts: 2667
Joined: Sun Jul 26, 2009 7:59 pm
Location: EST
Name: David King

Re: phpBB Standalone Template Engine

Post by imkingdavid » Mon Nov 08, 2010 2:09 am

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?
Don't forget to smile today. :)
Please do NOT contact for support via PM or email.
Remember, the enemy's gate is down.

DreamCrafter
Registered User
Posts: 20
Joined: Thu Sep 09, 2010 10:52 pm
Location: United Kingdom
Name: Daniel Dickson
Contact:

Re: phpBB Standalone Template Engine

Post by DreamCrafter » Wed Nov 10, 2010 12:36 am

The Template Engine doesn't seam to work when you use it with the $_GET Query function. It displays the previous page as well as the Queried Page is their a way to bypass it like the phpBB software does?

NguyTieuNhan
Registered User
Posts: 96
Joined: Fri Nov 21, 2008 12:31 am

Re: phpBB Standalone Template Engine

Post by NguyTieuNhan » Sun Dec 19, 2010 2:20 pm

I have code:

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&#7917;i &#432;&#7899;c nguy&#7879;n </a> <img src="images/03.gif" width="16" height="16" /> <a href="list.php"> Xem danh s&#225;ch </a> <img src = "images/04.gif" width = "27" height = "18" /> <a href="http://hagiangpro.com" target="_blank"> &#272;&#7885;c b&#225;o </a> <img src = "images/05.gif "width ="15"height ="12"/> <a href="../index.php"> Quay l&#7841;i di&#7877;n &#273;&#224;n </a> <img src ="images/06.gif"width ="16" height = "16" /> <a href="http://hagiangpro.com/"> Tin t&#7913;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&#7901;i &#432;&#7899;c s&#7889;:<?=$id?><img src="images/close.gif" alt="&#272;&#243;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="&#7844;n &#273;&#7875; ch&#250;c cho l&#7901;i &#432;&#7899;c th&#224;nh s&#7921; th&#7853;t">&#272;&#227; &#273;&#432;&#7907;c ch&#250;c: <?=$cs?> l&#7847;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">&#431;&#7899;c nguy&#7879;n</a> - 

	Powered by N</div></div>

</body></html>
<?
if(isset($_GET['id'])) {
echo "<script type=\"text/javascript\">Show(".$_GET['id'].");</script>";
}else {
}
?>
I use it to make phpbb mods
Them I Creat 2 files:
index.php:

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();
    ?>
and index_body.html

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&#7917;i &#432;&#7899;c nguy&#7879;n </a> <img src="{T_THEME_PATH}/love/images/03.gif" width="16" height="16" /> 
<a href="list.php"> Xem danh s&#225;ch </a> <img src = "{T_THEME_PATH}/love/images/04.gif" width = "27" height = "18" />
 <a href="http://hagiangpro.com" target="_blank"> &#272;&#7885;c b&#225;o </a> <img src = "{T_THEME_PATH}/love/images/05.gif" width ="15"height ="12"/> 
 <a href="../index.php"> Quay l&#7841;i di&#7877;n &#273;&#224;n </a> <img src ="{T_THEME_PATH}/love/images/06.gif"width ="16" height = "16" /> 
 <a href="http://hagiangpro.com/"> Tin t&#7913;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&#7901;i &#432;&#7899;c s&#7889;:{ID}<img src="{T_THEME_PATH}/love/images/close.gif" alt="&#272;&#243;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="&#7844;n &#273;&#7875; ch&#250;c cho l&#7901;i &#432;&#7899;c th&#224;nh s&#7921; th&#7853;t">&#272;&#227; &#273;&#432;&#7907;c ch&#250;c: {CS} l&#7847;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">&#431;&#7899;c nguy&#7879;n</a> - 

	Powered by N</div></div>



<!-- INCLUDE love/love_footer.html -->
When I run index.php it have error

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)
Please help me to fix this.
Thanks for Support.

TheMadCat
Registered User
Posts: 2
Joined: Sat May 28, 2011 7:19 pm

Re: phpBB Standalone Template Engine

Post by TheMadCat » Sat May 28, 2011 7:46 pm

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?

You still run into problems with phpbb 3.0.8 Standalone Template Engine.
For example caching. Look at where the global variable are and how they interact with the code.

TheMadCat
Registered User
Posts: 2
Joined: Sat May 28, 2011 7:19 pm

Re: phpBB Standalone Template Engine

Post by TheMadCat » Sat May 28, 2011 8:32 pm

NguyTieuNhan wrote:I have code:....
(To long to quote)

Edit: Miss read his/her post. Correct replay.
Edit: I reading up on request_var(). Take a look about it. Its better way then doing $_GET['id'] part.

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>


samuelgozi
Registered User
Posts: 15
Joined: Wed Jun 29, 2011 6:01 pm

Re: phpBB Standalone Template Engine

Post by samuelgozi » Wed Jun 29, 2011 6:07 pm

can anyone upload a demo so i can see how to make it work on the last version?
i tried all what you write here, but my web site just show a blank screen.
please upload a simple demo, it will help me a lot.

samuelgozi
Registered User
Posts: 15
Joined: Wed Jun 29, 2011 6:01 pm

Re: phpBB Standalone Template Engine

Post by samuelgozi » Wed Jun 29, 2011 8:31 pm

If you want it to work with the files of phpBB 3.0.8 you will need to find:

Code: Select all

		$data = "<?php if (!defined('IN_PHPBB')) exit;" . ((strpos($data, '<?php') === 0) ? substr($data, 5) : ' ?>' . $data);
and remove it.

can some one told me how can i add my own classes?
i mean somthing like - {SOME_TEXT}.

doddsey_65
Registered User
Posts: 2
Joined: Thu Jul 07, 2011 2:14 pm

Re: phpBB Standalone Template Engine

Post by doddsey_65 » Thu Jul 07, 2011 6:05 pm

hi, i downloaded the code from pastebin and everything worked fine until i used block_vars. I used xxx.S_FIRST_ROW and got the following error:

Undefined index: S_FIRST_ROW

anyone know why this happens?

indra
Registered User
Posts: 104
Joined: Fri Dec 31, 2010 8:20 am
Location: North Sumatra - Indonesia
Name: Indra Gunawan
Contact:

Re: phpBB Standalone Template Engine

Post by indra » Thu Dec 22, 2011 8:37 am

how to use it with phpbb 3.0.9 template core. i cant find you say to change.

please help me. i'm so interested with phpbb template system

Angel200
Registered User
Posts: 26
Joined: Fri Apr 28, 2006 11:19 am
Location: 127.0.0.1:1337
Contact:

Re: phpBB Standalone Template Engine

Post by Angel200 » Tue Mar 13, 2012 4:57 pm

EDIT:
Get it to work i forget to delete the following in the template.php

Code: Select all

    if (!defined('IN_PHPBB'))
    {
        exit;
    }
      

Locked

Return to “[3.0.x] MOD Writers Discussion”