473,685 Members | 2,906 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

+ 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**

+ 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}
- 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 1828

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.


Sascha Tayefeh

Oct 10 '07 #2

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

Similar topics

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 which is compiled and works fine. ############################################
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: virtual void do_bar() {} };
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 template for your type. However, this requires you to copy the whole template, and change the method, which leads to code duplication... If there's only 1 template parameter, one can specialize the method
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 specialize Music<Bach>, I expect that the original play() method is available in the specialization, but it is not. How can I fix this? -X
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 before asking the question so as you can understand what I am trying to accomplish. Any help would be much appreciated.
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 argument and deducing the type of them. I want to make a library which I can use like that: class_<fs::path, sq_filesystem::ttag>(v, "path", no_base)
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 major issue. I just need looping and conditionals. Template inheritance would be a
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 implementation: http://tt2.org/python/index.html I created this port both as a fun programming project, and for use in environments where Perl is not available, for reasons technical, cultural, or otherwise. The extensive Perl test suites...
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 method(foo<Tl, foo<Ur); // But VC2008 requires this
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.