TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 10-14-2008, 07:10 AM   #1 (permalink)
The Contributor
 
awuehr's Avatar
 
Join Date: Oct 2008
Location: Nuremberg, Germany
Posts: 26
Thanks: 3
awuehr is on a distinguished road
Plugin/Addon What do you think about PHPTAL?

Hi folks,

I'm curios if you know PHPTAL and what you think about it. IMHO it's the best templating system available for PHP. No PHP code or proprietary tags in the template files, just valid XML/XHTML.

But what's your opinion?


Best regards,

Alex
Send a message via ICQ to awuehr Send a message via Skype™ to awuehr
awuehr is offline  
Reply With Quote
The Following 2 Users Say Thank You to awuehr For This Useful Post:
codefreek (10-24-2008), Runar (11-06-2008)
Old 10-14-2008, 08:54 AM   #2 (permalink)
The Frequenter
Newcomer 
 
xenon's Avatar
 
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
xenon is on a distinguished road
Default

It kicks ass. Also has integrated internationalization, besides forcing you to write valid XHTML and it's way faster than Smarty.
__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.
xenon is offline  
Reply With Quote
The Following User Says Thank You to xenon For This Useful Post:
awuehr (10-14-2008)
Old 10-14-2008, 07:05 PM   #3 (permalink)
The Prestige
Advanced Programmer Top Contributor Good Samaritan 
 
sketchMedia's Avatar
 
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
sketchMedia is on a distinguished road
Default

Looks interesting, thanks
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)
sketchMedia is offline  
Reply With Quote
Old 10-24-2008, 01:09 AM   #4 (permalink)
Super Moderator
Inquisitive 
 
codefreek's Avatar
 
Join Date: Sep 2007
Location: Near you.
Posts: 791
Thanks: 241
codefreek is on a distinguished road
Default

Quote:
Originally Posted by sketchMedia View Post
Looks interesting, thanks
what he said ;)
codefreek is offline  
Reply With Quote
Old 10-24-2008, 08:34 AM   #5 (permalink)
The Contributor
 
awuehr's Avatar
 
Join Date: Oct 2008
Location: Nuremberg, Germany
Posts: 26
Thanks: 3
awuehr is on a distinguished road
Default

I think a poll about what template engines people use could be interesting. But which PHP template engines except from Smarty and PHPTAL are worth to be mentioned?
Send a message via ICQ to awuehr Send a message via Skype™ to awuehr
awuehr is offline  
Reply With Quote
Old 11-06-2008, 12:29 PM   #6 (permalink)
The Contributor
 
Runar's Avatar
 
Join Date: Nov 2008
Location: Norway
Posts: 58
Thanks: 20
Runar is on a distinguished road
Default

I am considering implanting this on my site, but I do have one issue: In my opinion, a template system does not only separate backend from frontend, but it also makes sure I do not have to repeat i.e. my HTML header on every file. How may I do this in PHPTAL?

I used to include a header file on top of every page, but this does not work with PHPTAL.
Send a message via MSN to Runar
Runar is offline  
Reply With Quote
Old 11-06-2008, 01:51 PM   #7 (permalink)
The Contributor
 
awuehr's Avatar
 
Join Date: Oct 2008
Location: Nuremberg, Germany
Posts: 26
Thanks: 3
awuehr is on a distinguished road
Default

Hi Runar,

this is done via Macros.

Lets say you have one file (macros.html) containing your header, footer, etc. containing this code:

HTML Code:
<div metal:define-macro="header">
    Your header here
</div>

<div metal:define-macro="footer">
    Your footer here
</div>
In your HTML page you just write
HTML Code:
<div metal:use-macro="macros.html/header" />
and
HTML Code:
<div metal:use-macro="macros.html/footer" />
where you want them to be.

Way better is to use slots:
Lets say you have one template for all your pages (template.html):

HTML Code:
<html metal:define-macro="page_template">
   <head></head>
   <body>
        <tal:block metal:define-slot="content" />
   </body>
</html>
Create another file (page.html):
HTML Code:
<tal:block metal:use-macro="template.html/page_template">
    <tal:block metal:fill-slot="content">
        Your static Content here
        ${dynamic_content}
        or
        <span tal:content="another_dynamic_content" />
    </tal:block>
</tal:block>
To render this just call

PHP Code:
$phptal = new PHPTAL();
$phptal->setSource('page.html');
$phptal->dynamic_content 'something';
$phptal->another_dynamic_content 'something else';

echo 
$phptal->execute(); 
That's all. Btw. you can define and fill more than one slot...

You should also read the manual for PHPTAL on PHPTAL :: Template Attribute Language for PHP

Greetings,

Alex

Last edited by awuehr : 11-06-2008 at 04:14 PM.
Send a message via ICQ to awuehr Send a message via Skype™ to awuehr
awuehr is offline  
Reply With Quote
The Following User Says Thank You to awuehr For This Useful Post:
Runar (11-06-2008)
Old 11-06-2008, 02:40 PM   #8 (permalink)
The Contributor
 
Runar's Avatar
 
Join Date: Nov 2008
Location: Norway
Posts: 58
Thanks: 20
Runar is on a distinguished road
Default

Ah, great! I was looking for something like that in the manual, but tried to understand the basics first. Now it works perfectly!

I will try to solve my last issue myself, but in case you already know the solution: I want to display an extra </tr><tr> if the number of people repeated (with tal:repeat) is 4. Any suggestions?

Edit: I followed your example, but had to replace metal:fill-slot="content" with metal:define-slot="content" in template.html.
Send a message via MSN to Runar
Runar is offline  
Reply With Quote
Old 11-06-2008, 03:46 PM   #9 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

Does anyone have a tutorial how to integrate this into zend framework??
__________________
Tanax is offline  
Reply With Quote
Old 11-06-2008, 03:54 PM   #10 (permalink)
The Contributor
 
awuehr's Avatar
 
Join Date: Oct 2008
Location: Nuremberg, Germany
Posts: 26
Thanks: 3
awuehr is on a distinguished road
Default

You should consider to use an 3d array like
PHP Code:
$phptal->persons = array(
    array(
'person1''person2''person3''person4'),
    array(
'person5''person6''person7''person8'),
    array(
'person9''person10''person11''person12')
); 
HTML would be
HTML Code:
<table>
    <tr tal:repeat="person_line persons">
        <td tal:repeat="person person_line" tal:content="person">...</td>
    </tr>
</table>
Greetings,

Alex
Send a message via ICQ to awuehr Send a message via Skype™ to awuehr
awuehr is offline  
Reply With Quote
The Following User Says Thank You to awuehr For This Useful Post:
Runar (11-06-2008)
Old 11-06-2008, 03:57 PM   #11 (permalink)
The Contributor
 
awuehr's Avatar
 
Join Date: Oct 2008
Location: Nuremberg, Germany
Posts: 26
Thanks: 3
awuehr is on a distinguished road
Default

Eat this: Zend_View_PhpTal - Matthew Ratzloff - Zend Framework Wiki
I don't know if it works with current releases of ZF, but i've used that successfully with ZF 1.5

Greetings


Alex
Send a message via ICQ to awuehr Send a message via Skype™ to awuehr
awuehr is offline  
Reply With Quote
The Following User Says Thank You to awuehr For This Useful Post:
Tanax (11-06-2008)
Old 11-06-2008, 04:56 PM   #12 (permalink)
The Contributor
 
awuehr's Avatar
 
Join Date: Oct 2008
Location: Nuremberg, Germany
Posts: 26
Thanks: 3
awuehr is on a distinguished road
Default

Btw you can use PHPTAL for templating any XML-Output like RSS/Atom feeds or XSL-FO where XSLT transformation is oversized.


Greetings

Alex
Send a message via ICQ to awuehr Send a message via Skype™ to awuehr
awuehr is offline  
Reply With Quote
Old 11-07-2008, 08:38 AM   #13 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

awuehr, you seem quite knowledged with PHPTAL. You're not considering to make a tutorial?
__________________
Tanax is offline  
Reply With Quote
Old 11-07-2008, 09:11 AM   #14 (permalink)
The Contributor
 
awuehr's Avatar
 
Join Date: Oct 2008
Location: Nuremberg, Germany
Posts: 26
Thanks: 3
awuehr is on a distinguished road
Default

Good idea. I really should do this, but I am not very good explaining technical things in english.

Is there a possibility to preview an article?
Send a message via ICQ to awuehr Send a message via Skype™ to awuehr
awuehr is offline  
Reply With Quote
Old 11-07-2008, 09:50 AM   #15 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

I'm sure you'll do absolutely great

No it doesn't look like you can =/
__________________
Tanax is offline  
Reply With Quote
Old 11-07-2008, 10:30 AM   #16 (permalink)
The Contributor
 
Runar's Avatar
 
Join Date: Nov 2008
Location: Norway
Posts: 58
Thanks: 20
Runar is on a distinguished road
Default

PHPTAL was surprisingly easy to understand. The manual explains everything quite well, but I would not say no to a tutorial. It is always better to understand when and how to use the different functions, not only how they work and what they do.
Send a message via MSN to Runar
Runar is offline  
Reply With Quote
Old 11-10-2008, 09:30 AM   #17 (permalink)
The Contributor
 
awuehr's Avatar
 
Join Date: Oct 2008
Location: Nuremberg, Germany
Posts: 26
Thanks: 3
awuehr is on a distinguished road
Default

First part (basics) of a short tutorial is waiting to be approved... :)


Greetings,

Alex
Send a message via ICQ to awuehr Send a message via Skype™ to awuehr
awuehr is offline  
Reply With Quote
Old 11-10-2008, 09:52 AM   #18 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

Awesome I'll check it as soon as it goes public
__________________
Tanax is offline  
Reply With Quote
Old 11-10-2008, 10:04 AM   #19 (permalink)
The Contributor
 
awuehr's Avatar
 
Join Date: Oct 2008
Location: Nuremberg, Germany
Posts: 26
Thanks: 3
awuehr is on a distinguished road
Default

But the first one is VERY basic...
Send a message via ICQ to awuehr Send a message via Skype™ to awuehr
awuehr is offline  
Reply With Quote
Old 11-10-2008, 10:07 AM   #20 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

Yea well, I haven't really done anything in PHPTAL, so that's just good that it's basic
__________________
Tanax is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 02:49 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design