Update:Archive/2.0/Developers/Templates: Difference between revisions

no edit summary
No edit summary
No edit summary
 
(20 intermediate revisions by 5 users not shown)
Line 1: Line 1:
[[Update:Home_Page|Update: Home Page]] » [[Update:Suggestions|Suggestions]] » Templates
{{AmoArchive}}


Templates
== Templates ==
Discussion
A template engine for the web should meet certain criteria.
 
http://wact.sourceforge.net/index.php/GoodTemplateSmells
# Pass the Dreamweaver test.
# Simplicity.
# Validating.
# Cacheable.
# Self-Inspecting.
# Secure.
# Flexibility.
 
=== Templating Engines for Consideration ===
# PHP (yep PHP itself is a template engine)
# [http://smarty.php.net Smarty]
# XSLT - technically XSLT is also a template engine
# [http://pear.php.net/HTML_Template_Flexy PEAR::HTML_Template_Flexy]
# [http://pear.php.net/HTML_Template_IT PEAR::HTML_Template_IT]
# [http://pear.php.net/HTML_Template_PHPLIB PEAR::HTML_Template_PHPLIB]
# [http://pear.php.net/HTML_Template_Sigma PEAR::HTML_Template_Sigma]
# [http://pear.php.net/HTML_Template_Xipe PEAR::HTML_Template_Xipe]
# [http://www.php-tools.de/site.php?file=/patTemplate/overview.xml patTemplate]
# [http://phptal.sourceforge.net/ PHPTAL] (port of Zope templates)
# [http://phpsavant.sourceforge.net/ PHP Savant] - reclaiming PHP
# [http://simplet.sourceforge.net SimpleT] - also reclaiming PHP
# [http://yats.sourceforge.net/ YATS - Yet Another PHP Templating System]
# [http://yapter.sourceforge.net/ YAPTER] (yet another yet another?)
# [http://vtemplate.sourceforge.net/ Virtual Template] (French)
# [http://phplib.sourceforge.net/ PHPLib]
# [http://ets.sourceforge.net/ ETS - Easy Template System]
# [http://avantemplate.sourceforge.net/ AvantTemplate]
# [http://sourceforge.net/projects/xtpl/ XTemplate]
# [http://htmltmpl.sourceforge.net/ htmltmpl]
# [http://sourceforge.net/projects/bleetz Bleetz]
# [http://asaplate.sourceforge.net/ ASAPlate]
# [http://sourceforge.net/projects/phpdudlik/ DTE]
# [http://enzyme.sourceforge.net/ Enzyme Template] (part of a mini framework)
# [http://sourceforge.net/projects/php-service/ PHP-Service]
# [http://sourceforge.net/projects/qtpl/ Quick Template]
# [http://sledgehammer.sourceforge.net/ Sledgehammer]
# [http://www.sourceforge.net/projects/phpmarker PHPMarker]
# [http://tpln.sourceforge.net/ TPLN]
# [http://www.phpclasses.org/browse.html/package/1132.html FT]
# [http://www.phpclasses.org/browse.html/package/98.html ATemplate]
# [http://www.phpclasses.org/browse.html/package/937.html ctlTpl]
# [http://www.phpclasses.org/browse.html/package/1095.html hierarchy template]
# [http://www.phpclasses.org/browse.html/package/361.html InTemplate]
# [http://www.phpclasses.org/browse.html/package/903.html lorenphplib_patternizer]
# [http://www.phpclasses.org/browse.html/package/807.html MyTemplate]
# [http://www.phpclasses.org/browse.html/package/1111.html Path Wrapper]
# [http://www.phpclasses.org/browse.html/package/905.html phpoot]
# [http://www.phpclasses.org/browse.html/package/1032.html Smart Template]
# [http://www.phpclasses.org/browse.html/package/658.html Templato]
# [http://www.phpbb.com phpBB template engine]
# [http://www.thewebmasters.net/php/FastTemplate.phtml Fast Template]
# [http://www.astrofoto.org/people/roland/rFT/ FastTemplate Clone] - drop in replacement for FastTemplate.
# [http://www.tinybutstrong.com/ Tiny But Strong]
# [http://www.simpleturtle.com/template/ Simple Turtle Template]
# [http://www.source-code.biz/MiniTemplator/ MiniTemplator]
# [http://www.virtualcreations.com.au/mark/tagtemplate.htm TagTemplate]
# [http://templatepower.codocad.com/ Template Power]
# [http://vlib.activefish.com/ vLibTemplate]
# [http://www.phpguru.org/template.html Richard Hayes Template class]
# [http://www.bugi.biz/ Bugi Template]  (site is down?  [http://www.hotscripts.com/Detailed/14787.html hotscripts entry])
# [http://www.massassi.com/bTemplate/index.php?page=home bTemplate]
# [http://pukomuko.esu.lt/phemplate/ Phemplate]
# [http://templeet.org/ Templeet]
# eZ Publish 2.x Templates
# [http://ez.no/sdk/tutorials/view/templateissues eZ Publish 3.x Templates] - very different to 2.x
# [http://templatepower.codocad.com/ TemplatePower]
# [http://www.muze.nl/en/software/template/ Muze Template]
# [http://www.servability.com/products/free/logictemplate/ Logic Template] - not sure about this one - seems to be about turning PHP into an intepreter
# [http://www.maiatech.com/varpage.php varpage] (formerly known as ShellPage)]
# PHP-DOM extension (HTML support)
# [http://demo.deluxeportal.com/ Template-X]
# [http://kuerbis.org/template/ KTemplate (former Apolda Template)]
# [http://www.jvmultimedia.com/home/articles.php?articleId=8 EZ Template]
# [http://4arrow.com/apps/template_compiler/ 4Arrow Template Compiler]
# [http://dutchtpl.devfusion.nl/ dutchtpl]
# [http://www.xaraya.com/ Xaraya] - implements it's own template engine
# [http://www.millipede.nl/ectemplate/ ecTemplate]
# [http://www.freetemplate.de/ Freetemplate]
# [http://modelixe.phpedit.com/ ModelIxe]
# [http://monsite.wanadoo.fr/phptempt/ PHPTempt]
# [http://simonster.com/software/sstp/ Server Side Template Parser]
# [http://andy.greyledge.net/voot/index.php Vanilla Object Oriented Templates]
# [http://www.vbulletin.com vBulletin] - has it's own template langauge
# [http://extemplates.narod.ru/ ExTemplates]
# [http://www.templatetamer.com/ TemplateTamer]
 
== Discussion ==
http://www.sitepoint.com/forums/showthread.php?threadid=123769
http://www.sitepoint.com/forums/showthread.php?threadid=123769
http://wact.sourceforge.net/index.php/TemplateView
http://wact.sourceforge.net/index.php/TemplateView
A template engine for the web should meet certain criteria. For me, this criteria is the following:
http://wact.sourceforge.net/index.php/GoodTemplateSmells
1. Pass the Dreamweaver test.
2. Simplicity.
3. Validating.
4. Cacheable.
5. Self-Inspecting.
6. Secure.
7. Flexibility.


=== morgamic's take ===
=== morgamic's take ===
Line 28: Line 108:
But if we can use CSS properly, all HTML output will be exactly the same with the exception of DOM identifiers when appropriate, using templating or skinning the whole app should be reduced to a matter of switching stylesheets.  From there, it's just a matter of packaging your markup properly, which is not something I see us needing a separate tool for.
But if we can use CSS properly, all HTML output will be exactly the same with the exception of DOM identifiers when appropriate, using templating or skinning the whole app should be reduced to a matter of switching stylesheets.  From there, it's just a matter of packaging your markup properly, which is not something I see us needing a separate tool for.


<pre>
1. PHP (yep PHP itself is a template engine)<br />
2. <a href="http://smarty.php.net">Smarty</a><br />
3. XSLT - technically XSLT is also a template engine<br />
4. <a href="http://pear.php.net/HTML_Template_Flexy">PEAR::HTML_Template_Flexy</a><br />
5. <a href="http://pear.php.net/HTML_Template_IT">PEAR::HTML_Template_IT</a><br />


6. <a href="http://pear.php.net/HTML_Template_PHPLIB">PEAR::HTML_Template_PHPLIB</a><br />
: mvl's comments: A template engine is definitly worth it. It is not about CSS. It is about readable code. html all over the php code makes the php unreadable. php all over the html code makes the html unreadable. You really want to split it. (and having it split up reduces the risk of cvs conflicts) --[[User:Mvl|Mvl]] 10:51, 22 Jan 2005 (PST)
7. <a href="http://pear.php.net/HTML_Template_Sigma">PEAR::HTML_Template_Sigma</a><br />
8. <a href="http://pear.php.net/HTML_Template_Xipe">PEAR::HTML_Template_Xipe</a><br />
9. <a href="http://www.php-tools.de/site.php?file=/patTemplate/overview.xml">patTemplate</a><br />
10. <a href="http://phptal.sourceforge.net/">PHPTAL</a> (port of Zope templates)<br />


11. <a href="http://phpsavant.sourceforge.net/">PHP Savant</a> - reclaiming PHP<br />
: morgamic's comments: I think I may have not been thinking enough about the people responsible for UMO's design. The need for a good engine that can accomodate them and allow them the ability to change look and feel without mucking with CVS would be a great feature -- mconner helped explain that to me. UMO will be very different from Bouncer in that respect, so maybe I have to read up more on templating engines. :)
12. <a href="http://simplet.sourceforge.net">SimpleT</a> - also reclaiming PHP<br />
13. <a href="http://yats.sourceforge.net/">YATS - Yet Another PHP Templating System</a><br />
14. <a href="http://www.phpbb.com">phpBB template engine</a><br />
15. <a href="http://www.thewebmasters.net/php/FastTemplate.phtml">Fast Template</a><br />


16. <a href="http://www.tinybutstrong.com/">Tiny But Strong</a><br />
=== alanjstr's take ===
17. <a href="http://yapter.sourceforge.net/">YAPTER</a> (yet another yet another?)<br />
18. <a href="http://www.simpleturtle.com/template/">Simple Turtle Template</a><br />
19. <a href="http://www.source-code.biz/MiniTemplator/">MiniTemplator</a><br />
20. <a href="http://www.virtualcreations.com.au/mark/tagtemplate.htm">TagTemplate</a><br />
21. <a href="http://www.ultratemplate.com/main.php">http://www.ultratemplate.com/main.php</a><br />
22. <a href="http://templatepower.codocad.com/">Template Power</a><br />


23. <a href="http://vtemplate.sourceforge.net/">Virtual Template</a> (French)<br />
We definitely need to move from having the html all over the php. I don't think anyone will disagree with that. Templating allows us to separate the data from the presentation. I'm all for using CSS. But the html it applies to is what we need to work on.
24. <a href="http://vlib.activefish.com/">vLibTemplate</a><br />
25. <a href="http://sourceforge.net/projects/xtpl/">XTemplate</a><br />
26. <a href="http://www.phpguru.org/template.html">Richard Hayes Template class</a><br />
27. <a href="http://www.bugi.biz/">Bugi Template</a>  (site is down?  <a href="http://www.hotscripts.com/Detailed/14787.html">hotscripts entry</a>)<br />


28. <a href="http://www.massassi.com/bTemplate/index.php?page=home">bTemplate</a><br />
The sidebar is an example.  We have different kinds of sidebars.  We have one for themes, one for extensions, one for developers ... Instead of us making a whole sidebar module that does echos, we can use a template that accepts data and turns it into presentation.
29. <a href="http://pukomuko.esu.lt/phemplate/">Phemplate</a><br />
Consider this example I wrote using Smarty
30. <a href="http://templeet.org/">Templeet</a><br />
<pre>
31. <a href="http://htmltmpl.sourceforge.net/">htmltmpl</a>
<!-- Incomplete PHP Wrapper -->
32. <a href="http://phplib.sourceforge.net/">PHPLib</a>
include('Smarty.class.php');
32. eZ Publish 2.x Templates<br />
$smarty = new Smarty;
33. <a href="http://ez.no/sdk/tutorials/view/templateissues">eZ Publish 3.x Templates</a> - very different to 2.x</a>
$smarty->assign('categories',
34. <a href="http://templatepower.codocad.com/">TemplatePower</a><br />
  array()
35. <a href="http://www.muze.nl/en/software/template/">Muze Template</a><br />
)
36. <a href="http://ets.sourceforge.net/">ETS - Easy Template System</a><br />
</pre>
37. <a href="http://avantemplate.sourceforge.net/">AvantTemplate</a><br />
<pre>
38. <a href="http://www.servability.com/products/free/logictemplate/">Logic Template</a> - not sure about this one - seems to be about turning PHP into an intepreter<br />
<!-- Sample Template -->
<div id="side">
  <ul id="nav">
  {section name=i loop=$categories}
    {if $categories[i].subcats[0]}
      <li><ul>
      {section name=j loop=$categories[i].subcats}
        <li><a href="showlist.php?category={$categories[i].subcats[j].catname}"
              title="{$categories[i].subcats[j].catdesc}">
            {$categories[i].subcats[j].catname}</a></li>
      {/section}
      </ul></li>
    {else}
      <li><a href="showlist.php?category={$categories[i].catname}"  
            title="{$categories[i].catdesc}">{$categories[i].catname}</a></li>
    {/if}   
  {/section}
  </ul>
</div>
</pre>


39. <a href="http://www.maiatech.com/varpage.php">varpage</a> (formerly known as ShellPage)</a>
<pre>
40. PHP-DOM extension (HTML support)
<!-- Sample Output -->
41. <a href="http://demo.deluxeportal.com/">Template-X</a>
<div id="side">
42. <a href="http://kuerbis.org/template/">KTemplate (former Apolda Template)</a><br />
  <ul id="nav">
43. <a href="http://www.jvmultimedia.com/home/articles.php?articleId=8">EZ Template</a><br />
    <li><a href="showlist.php?acategory=All" title="Show All Themes Alphabetically">All Themes</a></li>
44. <a href="http://4arrow.com/apps/template_compiler/">4Arrow Template Compiler</a><br />
    <li><ul>
 
      <li><a href="showlist.php?category=Animals" title="Animal Themes">Animals</a></li>
45. <a href="http://sourceforge.net/projects/phpdudlik/">DTE</a><br />
      <li><a href="showlist.php?category=Compact" title="Small icons">Compact</a></li>
46. <a href="http://enzyme.sourceforge.net/">Enzyme Template</a> (part of a mini framework)<br />
    </ul></li>
47. <a href="http://dutchtpl.devfusion.nl/">dutchtpl</a><br />
    <li><a href="showlist.php?category=Popular" title="Themes downloaded the most over the last week."><strong>Popular</strong></a></li>
48. <a href="http://www.xaraya.com/">Xaraya</a> - implements it's own template engine<br />
  </ul>
49. <a href="http://sourceforge.net/projects/bleetz">Bleetz</a> <br />
</div>
 
</pre>
50. <a href="http://asaplate.sourceforge.net/">ASAPlate</a><br />
51. <a href="http://www.millipede.nl/ectemplate/">ecTemplate</a><br />
52. <a href="http://www.freetemplate.de/">Freetemplate</a><br />
53. <a href="http://www.phpclasses.org/browse.html/package/1132.html">FT</a><br />
54. <a href="http://modelixe.phpedit.com/">ModelIxe</a>
55. <a href="http://www.astrofoto.org/people/roland/rFT/">FastTemplate Clone</a> - drop in replacement for FastTemplate.<br />
56. <a href="http://sourceforge.net/projects/php-service/">PHP-Service</a><br />
57. <a href="http://monsite.wanadoo.fr/phptempt/">PHPTempt</a><br />


58. <a href="http://sourceforge.net/projects/qtpl/">Quick Template</a><br />
All we do is pass in an array of data, and the template determines how to present it. We don't clutter our code with echo statements.
59. <a href="http://sledgehammer.sourceforge.net/">Sledgehammer</a><br />
60. <a href="http://simonster.com/software/sstp/">Server Side Template Parser</a><br />
61. <a href="http://andy.greyledge.net/voot/index.php">Vanilla Object Oriented Templates</a><br />
62. <a href="http://www.vbulletin.com">vBulletin</a> - has it's own template langauge<br />
64. <a href="http://www.phpclasses.org/browse.html/package/98.html">ATemplate</a><br />
65. <a href="http://www.phpclasses.org/browse.html/package/937.html">ctlTpl</a><br />
66. <a href="http://www.phpclasses.org/browse.html/package/1095.html">hierarchy template</a><br />


67. <a href="http://www.phpclasses.org/browse.html/package/361.html">InTemplate</a><br />
=== Colin's take ===
68. <a href="http://www.phpclasses.org/browse.html/package/903.html">lorenphplib_patternizer</a><br />
69. <a href="http://www.phpclasses.org/browse.html/package/807.html">MyTemplate</a><br />
70. <a href="http://www.phpclasses.org/browse.html/package/1111.html">Path Wrapper</a><br />
71. <a href="http://www.phpclasses.org/browse.html/package/905.html">phpoot</a><br />
72. <a href="http://www.phpclasses.org/browse.html/package/1032.html">Smart Template</a><br />


73. <a href="http://www.phpclasses.org/browse.html/package/658.html">Templato</a><br />
One thing most people seem to be agreed on is that it is best to extract the HTML code from within the PHP code, as it becomes unmanagable after a while. The problem is then which templating engine to use... certainly the ones I have had a quick glance at on the list above, they tend to seem to work by passing them a data-structure (Array usually) which they can then do something with.  
74. [http://extemplates.narod.ru/]ExTemplates[/url]
75. http://www.templatetamer.com/
76. http://sourceforge.net/project/showfiles.php?group_id=69763&release_id=172516
77. http://pinkgoblin.com/index.php?view=scripts
78. http://www.sourceforge.net/projects/phpmarker
79. http://tpln.sourceforge.net/
80. http://www.pgenie.org/


</pre>
The "standard" seems to be [http://smarty.php.net Smarty], and I've taken a look at [http://htmltmpl.sf.net HTMLTMPL] too and they seem to operate in the same way, it would be just a matter of deciding which was most suitable... I don't have an opinion on that, but I '''do''' think templating is the way to go.
canmove, Confirmed users, Bureaucrats and Sysops emeriti
1,043

edits