473,378 Members | 1,134 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Template systems - which method?

I'm looking for a good idea or ready library for templates. HTML with
PHP isn't the best solution (it's more difficult for end-users of CMS
to edit them). Perhaps, everything I need is:
- variables - e.g. {var}
- sections or conditions (some elements won't be printed out)
- loops or selecting fragments*
- cache (recommended for speed)

The template system must be fast and efficient. Most probably I will
create own library for CMS requirement. However, i think about
existing scripts, e.g. XT (XHTML Templates) and OPT (Open Power
Templates).

XT
+ based on XML (DOM functions)
+ templates are clean (without template language)
+ you can modify code properties (e.g. styles, colors, etc.) - DOM
functions are powerful too
+ quite fast
+/- for every template you create new XT object
- no cache (author thinks XT is fast and it isn't needed and XT parses
templates in real-time)
- no {var} support - everything is based on DOM**

OPT
+ cache
+ powerful
+ you are independent of language you use in templates (e.g.
HTML, ...?)
+/- only one instance optClass of template system (you can change
options, etc.)
+/- based on template language ({section=abc}{/section}, {if=...}{$var}
{/if}...)***
- compilation to .php files is slow
- template language can make editing templates more difficult (but
easier as with PHP code)
- large size of library's files

* Loops. In PHP i get news using unbuffered query and read them
through foreach loop.

foreach($res as $news) {...}

Perhaps, for server and script performance, CMS should send one news
after every iteration. There are 2 methods:
- You divide template into fragments and assign new data to "one news"
fragment in every iteration.
- You call a function (which exists in cache) in every iteration.
Eventually, template system can collect these data to put them later
but it uses more RAM.

** I prefer {var} variables. Imaginate that you assign an URL. You
don't know whether template has a link (which is more recommended)
with HREF attribute or whether it has <input type="button" /(Google
doesn't probably read it). I don't know other examples but look at
another issue. You want to put some text or other characters. You can
still do it but it isn't so easy:

<a>&raquo; <span id="here" /></a>

*** I think XT idea is better for code redability. But what with
caching? Is it needed? Remember that you must load template through
DOM functions.

Finally, let's say that template system has to:
- put values
- manage loops and sections
- delete section or condition's content when (...?....)****

**** Should I delete data from PHP? I think - no - I should add data
and the library should decide whether delete some blocks.

What are your opinions?
I paused creating the CMS because of problems with choosing a good
method of creating templates.

Oct 4 '07 #1
1 1812

Hi WebCM,

not quite sure if I got you right, but in case you are asking for
html-templates try Smarty at http://smarty.php.net/

I have incorporated the engine into one of my projects and it works
great as far as both, usability and performance is concerned.

Sincerly

Sascha Tayefeh

Oct 10 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Alex Vinokur | last post by:
========================================= Windows 2000 CYGWIN_NT-5.0 1.3.22(0.78/3/2) GNU gcc version 3.2 20020927 (prerelease) ========================================= Here is some program...
11
by: Dave Rahardja | last post by:
OK, so I've gotten into a philosophical disagreement with my colleague at work. He is a proponent of the Template Method pattern, i.e.: class foo { public: void bar() { do_bar(); } protected:...
2
by: SainTiss | last post by:
Hi, If you've got a template class with lots of methods, and then you've got a type which works with the template, except for one method... What you need to do there is specialize the...
8
by: Agent Mulder | last post by:
Hi group, I have a problem with partial template specialization. In the code below I have a template struct Music with one method, play(), and three kinds of music, Jazz, Funk and Bach. When I...
1
by: Greg Phillips | last post by:
Hello everyone, I have read the section on templates in The C++ Programming Language 3rd edition 3 times over the last 4 days. Still I am stumped. I'll explain a bit about what I am doing...
1
by: Adam Dziendziel | last post by:
Hi all! I'm writing a luabind/boost::python-like binding utility for a Squirrel language to generating wrapper-functions for C++ classes and have a problem with passing the pointer-to-member...
17
by: allen.fowler | last post by:
Hello, Can anyone recommend a simple python template engine for generating HTML that relies only on the Pyhon Core modules? No need for caching, template compilation, etc. Speed is not a...
4
by: eefacm | last post by:
I'd like to inform the Python community that the powerful and popular Template Toolkit system, previously available only in its original Perl implementation, is now also available in a beta Python...
2
by: Andy Champ | last post by:
We have a class with something that, simplified, looks like this: template <typename Tclass foo { T beyondAllReaching; // In VC2005, this works OK template <typename Ufriend void...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.