|
|
|
Currently, there are three different types of BML blocks. You were briefly introduced to two of them in the tutorial: Data and Full. However, there's also another one... Pipe. All a block type determines is how data inside the blocks, in between the (= and =) marks, gets parsed into the different variable names in the template .look file. Sometimes you want a lot of options and flexiblity, in which you'd probably use a Full block, but sometimes you just want something quick and easy to go inline with some text, in which you'd use a Data or Pipe block.
Each type of BML block is discussed in more detail below.
A data block, designated by the {D} identifier in .look file definitions, in the most simple type of BML block. Everything within the block is treated as one big chunk, called DATA. When you make your template definition, simply insert the text %%DATA%% and your data gets inserted into that area.
TITLE=>{D}<H1 ALIGN=CENTER>%%DATA%%</H1>
(=TITLE My Title Text TITLE=)
<H1 ALIGN=CENTER>My Title Text</H1>
Data blocks are good when you only have one variable to insert into your block and useful when you want to keep your BML code on a single line, but sometimes you need a little more...
Pipe blocks are good in that you can use more than one variable in your block definitions but you can still keep your BML on a single line. Pipe blocks are named as such because the different variables in your BML are separted by pipe characters (vertical bars).
Pipe blocks are used quite often. Perhaps you want to make a different sort of link for all links that lead away from your website... instead of just linking the page directly, you want to throw them against a cgi-script on your website that logs the request and then redirects them. Let's make a block called EL for external links.
EL=>{P}<A HREF="/cgi-bin/redirect?%%DATA1%%">%%DATA2%%</A>
Go visit (=EL http://www.netscape.com/|Netscape EL=)!
Go visit <A HREF="/cgi-bin/redirect?http://www.netscape.com/">Netscape</A>!
You could build on this example quite a bit. Lots of people use small little "leaving this site" images beside external links... others make their links look different... others have a splash page before they are redirected, warning users what's going on. It doesn't really matter. With BML just define external links once and if you ever change your mind as to what you're going to do, just change your template.
Full blocks allow you to use any number of variables, each being either single line or multi-line. Everything inside the block uses the same parsing logic as the .look files do, using the => and <= marks to mark single line entries and start/stop multi-line entries. Full blocks are most often used to define a site's page layout style, usually named PAGE. The .look file identifier for a full block is {F}.
PAGE<=
{F}<HTML>
<HEAD><TITLE>%%TITLE%%</TITLE></HEAD>
<BODY BGCOLOR=#FFFFCC>
<H1>%%TITLE%%</H1>
%%BODY%%
</BODY>
<=PAGE
(=PAGE TITLE=>Just an example BODY<= This is just an example page. How exciting, eh? <=BODY PAGE=)
<HTML> <HEAD><TITLE>Just an example</TITLE></HEAD> <BODY BGCOLOR=#FFFFCC> <H1>Just an example</H1> This is just an example page. How exciting, eh? </BODY>
Instead of having our data be named DATA or DATA1, DATA2, we get to decide what to call our variables. In this case we only had TITLE, a single line variable, and BODY a multi-line variable. And then, the whole .look file block was a multi-line definition. One interesting thing to note is that we used the %%TITLE%% variable placeholder twice in our .look file definition... that's okay to do, and actually quite useful. Keep in mind that this example is simplistic on purpose to save space and prevent confusion. In real situations your definition will be big and ugly, but at least you'll only need to do it once on your whole site, not on every page.
![]()
![]()
Return to BML Home.