Idea of using xml for templates

Source: Internet
Author: User
Tags php template
Some time ago, I had been more concerned about php's template skills and received a request from the customer: the whole site uses the template skills to control multiple templates. this project has a strong background request, the most important thing is multi-template. the difficulty lies in the guidance and identification of templates.

Some time ago, I had been more concerned about php's template skills and received a request from the customer: the whole site uses the template skills to control multiple templates. this project has a strong background request, the most important thing is the multi-template. the difficulty lies in the guidance and identification of the template. I carefully assessed the php template's core skills and searched for the start of the string, and then defined the variable change, switch to data and output it on the output page. I will not talk about the cache involved.

Let's take a look at the inherent problem of this method: if we want to display data in 'plain style', of course, I will not talk about CSS, and we cannot really separate the data and performance, the css style sheet method is nothing more than display. the project we receive now not only requests the selection of the css style sheet, but also requests the 'multi-method' of data display to give a metaphor, see:

In order to easily describe the period, we will show the following parts: A, B, C, D, E, F, and G, which can show the data display areas, from the designer's perspective, there are global (div holding A-G), TOP (A), LEFT (B), RIGHT (C, D, E, F) and FOOTER (G ), of course, you can divide it into more details. for this display, you can use div to hold it,But this is not a template technique., Please understand that A two‑dimensional table is not called A template. this is irrelevant to the template. The so-called template is only related to the 'data laking'. in data A, we can also form A navigation, for example. this is written in the traditional template technique as follows:

...

{$ SITE_TOP $} // cjjer creation

...

Replace () is a variable in the symbols {$ and $}. in the simple data, the metaphor is just a navigation, however, if we want a very complex data display, it will be difficult to hold it. it is difficult to ensure that there is no error because we put a large number of output data in a variable.

In addition, the traditional template (in php) is like this: get the template file, load, display, there is no title, the title is in the web project (incomplete is the website) when it is very complicated, it is easy to change errors and monotonous templates. although css can be used to hold some displays, it is difficult to control the layout of data. In comparison, I don't want e-zone today, you modify the template and reload the file ...?

Is there any easier solution?Yes.

I have put forward the following idea:

The template page is an XML document. the template node loads existing modules and loads 'XML-like data' natural files.(Sorry, I feel very easy to say so.) I will discuss this template technique in detail below.

Let's take a look at what modules I'm talking about. everyone knows, in html,

Here, of course, this label is meaningful to the project and represents the module node that holds the global control. if the node is displayed on the template page The loaded module data with the corresponding name format:

They all display some layout labels of the data layout. Why can't we create such labels ourselves? For example, I am creating a tag like this.

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.