 |
Account Login
|
 |
 |
Latest Articles
|
 |
 |
IRC Channel
|
 |
 |
Associates
|
 |
 |
Associates
|
 |
|
 |
|
 |
|
 |
10-14-2008, 07:10 AM
|
#1 (permalink)
|
|
The Contributor
Join Date: Oct 2008
Location: Nuremberg, Germany
Posts: 26
Thanks: 3
|
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
|
|
|
|
The Following 2 Users Say Thank You to awuehr For This Useful Post:
|
|
10-14-2008, 08:54 AM
|
#2 (permalink)
|
|
The Frequenter
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
|
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.
|
|
|
|
|
The Following User Says Thank You to xenon For This Useful Post:
|
|
10-14-2008, 07:05 PM
|
#3 (permalink)
|
|
The Prestige
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
|
Looks interesting, thanks
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)
|
|
|
|
10-24-2008, 01:09 AM
|
#4 (permalink)
|
|
Super Moderator
Join Date: Sep 2007
Location: Near you.
Posts: 791
Thanks: 241
|
Quote:
Originally Posted by sketchMedia
Looks interesting, thanks
|
what he said ;)
|
|
|
|
10-24-2008, 08:34 AM
|
#5 (permalink)
|
|
The Contributor
Join Date: Oct 2008
Location: Nuremberg, Germany
Posts: 26
Thanks: 3
|
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?
|
|
|
11-06-2008, 12:29 PM
|
#6 (permalink)
|
|
The Contributor
Join Date: Nov 2008
Location: Norway
Posts: 58
Thanks: 20
|
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.
|
|
|
11-06-2008, 01:51 PM
|
#7 (permalink)
|
|
The Contributor
Join Date: Oct 2008
Location: Nuremberg, Germany
Posts: 26
Thanks: 3
|
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.
|
|
|
|
The Following User Says Thank You to awuehr For This Useful Post:
|
|
11-06-2008, 02:40 PM
|
#8 (permalink)
|
|
The Contributor
Join Date: Nov 2008
Location: Norway
Posts: 58
Thanks: 20
|
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.
|
|
|
11-06-2008, 03:46 PM
|
#9 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
Does anyone have a tutorial how to integrate this into zend framework??
__________________
|
|
|
|
11-06-2008, 03:54 PM
|
#10 (permalink)
|
|
The Contributor
Join Date: Oct 2008
Location: Nuremberg, Germany
Posts: 26
Thanks: 3
|
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
|
|
|
|
The Following User Says Thank You to awuehr For This Useful Post:
|
|
11-06-2008, 03:57 PM
|
#11 (permalink)
|
|
The Contributor
Join Date: Oct 2008
Location: Nuremberg, Germany
Posts: 26
Thanks: 3
|
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
|
|
|
|
The Following User Says Thank You to awuehr For This Useful Post:
|
|
11-06-2008, 04:56 PM
|
#12 (permalink)
|
|
The Contributor
Join Date: Oct 2008
Location: Nuremberg, Germany
Posts: 26
Thanks: 3
|
Btw you can use PHPTAL for templating any XML-Output like RSS/Atom feeds or XSL-FO where XSLT transformation is oversized.
Greetings
Alex
|
|
|
11-07-2008, 08:38 AM
|
#13 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
awuehr, you seem quite knowledged with PHPTAL. You're not considering to make a tutorial? 
__________________
|
|
|
|
11-07-2008, 09:11 AM
|
#14 (permalink)
|
|
The Contributor
Join Date: Oct 2008
Location: Nuremberg, Germany
Posts: 26
Thanks: 3
|
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?
|
|
|
11-07-2008, 09:50 AM
|
#15 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
I'm sure you'll do absolutely great
No it doesn't look like you can =/
__________________
|
|
|
|
11-07-2008, 10:30 AM
|
#16 (permalink)
|
|
The Contributor
Join Date: Nov 2008
Location: Norway
Posts: 58
Thanks: 20
|
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.
|
|
|
11-10-2008, 09:30 AM
|
#17 (permalink)
|
|
The Contributor
Join Date: Oct 2008
Location: Nuremberg, Germany
Posts: 26
Thanks: 3
|
First part (basics) of a short tutorial is waiting to be approved... :)
Greetings,
Alex
|
|
|
11-10-2008, 09:52 AM
|
#18 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
Awesome  I'll check it as soon as it goes public 
__________________
|
|
|
|
11-10-2008, 10:04 AM
|
#19 (permalink)
|
|
The Contributor
Join Date: Oct 2008
Location: Nuremberg, Germany
Posts: 26
Thanks: 3
|
But the first one is VERY basic...
|
|
|
11-10-2008, 10:07 AM
|
#20 (permalink)
|
|
The Prestige
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
|
Yea well, I haven't really done anything in PHPTAL, so that's just good that it's basic 
__________________
|
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|