[ABD] Template Replacement MOD

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment! No new topics are allowed in this forum.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: MOD Development Forum rules

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.
Herbalite
Registered User
Posts: 205
Joined: Wed Apr 10, 2002 8:11 am
Location: South East Asia

[ABD] Template Replacement MOD

Post by Herbalite »

I've created a template engine that has some added functionality

- Added include command <!-- INCLUDE mytemplate.tpl --> (path requirements same as for set_filenames)

- Passing a template by var (allows to modifiy a template on the fly or loaded from a DB)

- Allows for PHP constructs (<?php .. ?> and <?= .. ?>) in templates. <? ... ?> constructs won't work at this time, but that isn't XML compliant anyway.

- Easy extensable for new commands as the main parser is token driven.

- Faster than the original template, especially when no block commands are in use

The parsing engine is a complete rewrite and needs at least PHP 4.0.5 to work.

I had an issue with the fileAttachment Mod, that I fixed and documented. I would be happy if some people around here can try out the template and tell me their expiriences and report if there are more incompatabilities.

Thanks

The file can be downloaded from http://www.pwsol.com/Ablage/template_replacement.zip
Last edited by Herbalite on Wed Nov 02, 2005 2:19 am, edited 1 time in total.
Herbalite
Registered User
Posts: 205
Joined: Wed Apr 10, 2002 8:11 am
Location: South East Asia

Re: Template Replacement MOD

Post by Herbalite »

Wanted to edit the message above as I forgot the Debugging info
Herbalite wrote: I've created a template engine that has some added functionality

- Added include command <!-- INCLUDE mytemplate.tpl --> (path requirements same as for set_filenames)

- Passing a template by var (allows to modifiy a template on the fly or loaded from a DB)

- Allows for PHP constructs (<?php .. ?> and <?= .. ?>) in templates. <? ... ?> constructs won't work at this time, but that isn't XML compliant anyway.

- Easy extensable for new commands as the main parser is token driven.

- Debugging (Can be configured to display missing Template substitues, or insert them as HTML comments)

- Faster than the original template, especially when no block commands are in use

The parsing engine is a complete rewrite and needs at least PHP 4.0.5 to work.

I had an issue with the fileAttachment Mod, that I fixed and documented. I would be happy if some people around here can try out the template and tell me their expiriences and report if there are more incompatabilities.

Thanks

The file can be downloaded from http://www.pwsol.com/Ablage/template_replacement.zip
PK Barbie Doll
Registered User
Posts: 71
Joined: Sun Sep 01, 2002 5:22 pm
Location: Uncharted Territories
Contact:

Post by PK Barbie Doll »

Thanks herbalite. I used your previous php in templates mod with success on several different forums. I will try this with a new forum I'm building (2.0.3) and let you know how it goes.
PK Barbie Doll
Registered User
Posts: 71
Joined: Sun Sep 01, 2002 5:22 pm
Location: Uncharted Territories
Contact:

Post by PK Barbie Doll »

Somebody give this guy a raise!

It works great right out of the box, no fuss whatsoever.

PHP is called in templates just the same as with any other php script...

<?
echo "Hello World";
?>

Works fine.. No need to shove everything on a single line like with the previous PHP in Templates mod. Also note that <? ?> is ok, as is <?php ?>

Environment variables are available as well. Depending on the version and configuration of your hosts PHP engine you would access them like:

$docroot = $DOCUMENT_ROOT or
$docroot = $_SERVER['DOCUMENT_ROOT'];

I haven't done anything complex yet, but the basic functionality of php is there. Thanks very much for this much improved template engine!

~ Adrya
dank
Registered User
Posts: 64
Joined: Fri Apr 19, 2002 3:25 pm
Contact:

Post by dank »

It sounds great, but I tried it out on one of my forums and still get the ol' eval() error from line 550:

eval ($codeline['value']);

I haven't really investigated what might be causing that, but I suspect eval() is going to be problematic no matter what.

Dan
NetMapel
Registered User
Posts: 58
Joined: Tue Dec 25, 2001 11:19 pm
Contact:

Post by NetMapel »

Pardon my very poor English skill, but I'm not getting what you're doing here. Are you making a new theme/style or something ?
Tremble before the power of Gaming Goddess !

PERFEQ Network - UNDER CONSTRUCTION
PERFEQ forums - UP FOR POSTING !
dank
Registered User
Posts: 64
Joined: Fri Apr 19, 2002 3:25 pm
Contact:

Post by dank »

No, it's a replacement for the standard template parser that is designed to make the templates more flexible by allowing PHP code to be used in them. Think of styles and themes as HTML and template parsing as programming, if that helps.

Dan
Herbalite
Registered User
Posts: 205
Joined: Wed Apr 10, 2002 8:11 am
Location: South East Asia

Post by Herbalite »

dank wrote: It sounds great, but I tried it out on one of my forums and still get the ol' eval() error from line 550:

eval ($codeline['value']);

I haven't really investigated what might be causing that, but I suspect eval() is going to be problematic no matter what.

Dan
Can't see how I get around that call to eval. I've elminiated all other evals that lurked in the original code.

But normally those kind of errors are some error in the code in the template itself. I don't know how much code it is, you could post the code here and I'll have a look at it.
Herbalite
Registered User
Posts: 205
Joined: Wed Apr 10, 2002 8:11 am
Location: South East Asia

Post by Herbalite »

PK Barbie Doll wrote: Works fine.. No need to shove everything on a single line like with the previous PHP in Templates mod. Also note that <? ?> is ok, as is <?php ?>

Yes since the first version I posted I was able to solve that problem.

As a nice side effect in templates BLOCK statements can be put as many as one need on the same line (as long as they are properly nested), and the parser won't choke or drop the rest of the line.

I need now to make sure it runs with 2.0.4 and then I'll submit the MOD.
dank
Registered User
Posts: 64
Joined: Fri Apr 19, 2002 3:25 pm
Contact:

Post by dank »

I believe the specific item causing the eval() error is the call to phpAdsNew in the included header. The rest of the PHP is being parsed correctly, but the header file dies with that one line.

Dan
Herbalite
Registered User
Posts: 205
Joined: Wed Apr 10, 2002 8:11 am
Location: South East Asia

Post by Herbalite »

dank wrote: No, it's a replacement for the standard template parser that is designed to make the templates more flexible by allowing PHP code to be used in them. Think of styles and themes as HTML and template parsing as programming, if that helps.

Dan
Actually one extension should make it easier to include subtemplate.

With the origoinal template engine we had to use {subtemplate} somewhere in a template. Then we had to add the code to include the template with assign_vars_form_handle. That coding step can be avoided if using <!-- INCLUDE subtemplate.tpl --> If the subtemplate contains template variables though they still will need to be coded as before. I'm looking into ways to eliminate that too. I made a carbon copy of the same template engine for Perl (Perl runs faster), and I already made a project where it's possible to define new template variables without changing the underlying code.
Herbalite
Registered User
Posts: 205
Joined: Wed Apr 10, 2002 8:11 am
Location: South East Asia

Post by Herbalite »

dank wrote: I believe the specific item causing the eval() error is the call to phpAdsNew in the included header. The rest of the PHP is being parsed correctly, but the header file dies with that one line.

Dan
I remember that one, I have a suggestion you might want to try out.

Put that entire statement between the starting and ending PHP tag into brackets { ... } effectively starting a new block. Add globals from phpAdsNew as you need them
dank
Registered User
Posts: 64
Joined: Fri Apr 19, 2002 3:25 pm
Contact:

Post by dank »

Put that entire statement between the starting and ending PHP tag into brackets...

Which entire statement? The only place I can think that you might mean is the site-wide header file with the phpAdsNew call, but doing what you are saying for the purpose of phpBB alone would make a mess of the rest of the site...

:?:

Dan
Herbalite
Registered User
Posts: 205
Joined: Wed Apr 10, 2002 8:11 am
Location: South East Asia

Post by Herbalite »

dank wrote:
Put that entire statement between the starting and ending PHP tag into brackets...

Which entire statement? The only place I can think that you might mean is the site-wide header file with the phpAdsNew call, but doing what you are saying for the purpose of phpBB alone would make a mess of the rest of the site...

:?:

Dan
I meant the PHP in the template.

However, it seems that the latest phpAdsNew version RC2 has provided support for template driven websites.

So on my testserver in index_body.tpl I tried
<?
include ("./../phpAdsNew/phpadsnew.inc.php");
view ("", 0);
?>


Works for me.
dank
Registered User
Posts: 64
Joined: Fri Apr 19, 2002 3:25 pm
Contact:

Post by dank »

I guess I don't follow what you're getting at with the brackets...
it seems that the latest phpAdsNew version RC2 has provided support for template driven websites.

That figures. I gave up on new versions of phpAdsNew quite a while ago (each one got more and more buggy, it seemed) and have stayed with v1.6. I've actually considered dropping the farce altogether, since it's not exactly like banner advertising pays any more. ;)

Dan
Locked

Return to “[2.0.x] MODs in Development”