蓝毒瘦脸针:Macros and XML

来源:百度文库 编辑:九乡新闻网 时间:2024/04/28 06:21:17

Macros and XML

It's time for a little theory. If you've been following this tutorial in order, you've already done some very advanced web site work. You've used two features of Manila that could save you hours of work in the future. Let's look at what each does.

Macros

Macros are a way to add custom content to your web site. (Technically, they are described as "Macros provide a way for you to include calculated elements in your Manila web pages and templates."

You've already used macros in the section Add a Comment. When you typed {commentIt.formMacro()} and {commentIt.commentsMacro()}, you were actually typing two macros - the first one added a button to the page and the second one shows the comments that have already been added.

But there are others. Try {whoAmI}. If you are logged into the site, this macro will show your name. You could use this macro for a custom greeting to your members - like Welcome {whoAmI} to our site!

Or {now} will show the current date and time. It will look like 3/7/2011; 2:30:13 PM. (Try reloading or refreshing your page and see how the time has changed

There are two major points to remember about macros:

  1. What you'll see on a web page when you use a macro may change. (As comments are added, the list of comments will change; The time will change with the now macro and the whoAmI macro will display different names depending on who is logged it.)
  2. You'll see a lot of macros as you start to change the way your site looks. You can tell its a macro because it starts with a curly brace { and ends with a curly brace }. Any time you see those curly braces true, it's probably a macro.

XML

XML stands for eXtensible Markup Language. For many, the very mention of those three letters in this order will cause their eyes to glaze over. It's been generally reserved for geeks.

XML helps give structure to your information (usually called data). It is useful.

You used XML in the section Add a Survey. The section where you changed the Responses was all XML. You were careful to keep all your choices between the tags and . You noted the first tag did not have a backslash - / but the second tag did. And you copied the choice words - Toto precisely.

Those are the main points to remember with XML:

  1. You make changes between tags
  2. Be precise.

You will see XML as you start to change the way your site looks or works. There's plenty of flexiblity. You may never have to edit XML. But if you do, the main thing to remember are those two points.

more information, refer to http://dl1.yukoncollege.yk.ca/help/macrosandxml