PHP Training: PHP templates with XML ideas (a)

Source: Internet
Author: User
Tags php template

Let us look at the disadvantages of this way of generating: if you want to "multi-style" display data, of course, I do not say that CSS, can not really separate the data and presentation, no outside the use of CSS style sheet to display only, we are now receiving this project not only requires CSS stylesheet optional, but also requires the data display " Multi-Way ", for example.

The following for easy description of the period, I represent the various parts: a,b,c,d,e,f,g These 6 areas can represent the data display area, from the designer's perspective, there is a global (Div control a-g), TOP (A), left (B), right (c,d,e,f) and footer (G Of course, you can divide the finer, so display, can be controlled with Div, but this is not a template technology, please understand that multi-style sheet is not called template, which is irrelevant to the template, so-called template, is only related to "data layout", in a data we can also be represented as a navigation, If you like. This is written in the traditional template technology:

... <div

Id= "Top" >{$SITE _top$}//cjjer production </div> Replace () is the {$

And the variable in the $} symbol, which is simply a navigation when the data is simple, and if we want a very complex data display, it is very difficult to control, because it is difficult to ensure that a large amount of output data in a variable is not error-prone.

In addition, the traditional template (in PHP) is like this, get template files, load, show Shanghai treatment of premature Ejaculation hospital, this is not a problem, the problem is when the Web project (not exactly a site) is very complex, it is easy to replace the error and template monotonous, although you can use CSS control some display, But it's hard to control the layout of the data, for example, E-zone I don't want it today, you change the template, reload the file ...

?

Is there an easier solution?

I put forward the view that:

The template page is

XML document, template node loads the existing module, loads the "Copy XML Data" Makefile (forgive me, so I think it's pretty easy) below I'll talk about this template technology.

First look at what I said the module is what, we all know, HTML <div> ah,<table> are showing some layout of the data layout label Shanghai's best sexual function treatment Hospital, why can't we make this label ourselves? For example: I am now "Chong" One such label <format> here, of course, this tag is meaningful for the project, which represents the control of the Global module node, if the node appears in the template page <format> load is the corresponding name called

Module data for format:

<! DOCTYPE

HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "http://w

Ww.w3c.org/tr/1999/rec-html401-19991224/loose.dtd ">

Xmlns= "http:/ww w.w3.org/1999/xhtml" >

http-equiv= "Content-type" content= "text/html; charset=gb2312 "/><meta

http-equiv= "Content-language" content= "ZH-CN"/><meta

Name= "Author" content= "[%author%]"/><meta

Name= "Copyright" content= "[%copyright%]"/><meta

Name= "description" content= "[%description%]"/><meta

Name= "keywords" content= "[%keywords%]"/><link

href= "Styles/[%styles%]/import.css" rel= "stylesheet" type= "Text/css"/>

id= "Format" >&%format%&</div></body>

Some time ago, has been more concerned about PHP template technology, I received a customer request: the entire station using template technology, you can control multi-template, this project requires a strong background, mainly multi-template, difficulties in the template import and recognition and generation, I carefully examined the PHP template core technology, No outside of the search string to start, and then define the substitution variables, replace the data, and then output page outputs, involved in the cache I will not say.

PHP Training: PHP templates with XML ideas (a)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.