Technical References - [interpret]

Interprets the enclosed [xxx] values using the WebDNA interpreter.

[interpret]Any Text and [xxx][/interpret]

To interpret [xxx] values stored in a database field, enclose them in an [interpret] context. For example, if you put the text "[date]" into a field in a database (text1, for instance), then when you display [text1] in a template it only shows the literal text "[date]" -- it will not try to interpret the contents of the field. [interpret][text1][/interpret], however, first substitutes "[date]" for text1, then interprets the result as "1/29/10."

Example:

[interpret]Some Text that contains [xxx] fields[/interpret]
Any WebDNA [xxx] tags are first substituted for their real values, which may contain more [xxx] tags. Then the resulting text and tags are interpreted as though they were typed into the template directly.

Why? A good example is a banner advertisement database: let's say you want to create a list of advertisements to display randomly at the top of every page in your site. This works well if the ads do not contain any [xxx] tags. But if you want to put [cart] information into the banner ad, you must use the [interpret] context to cause the [cart] variable to be substituted for its real value.

-----BannerAds.db------
AdNumber BannerHTML
1 <a href="Invoice.tpl?cart=[cart]">Invoice</a>
2 <img src="[random].gif">
-----------------------

Now let's look at a sample template that incorrectly uses the database above to randomly choose 1 item from the list and display the results at the top of a page:

<html><body>
[search db=BannerAds.db&neAdNumberdata=0&max=1&AdNumbersdir=ra&AdNumbersort=1]
[founditems][BannerHTML][/founditems]
[/search]
</body></html>

The problem here is that the [BannerHTML] is indeed evaluated and displayed, but it is incorrect because the [random] tag inside the field has not been evaluated to its true value:

<img src="[random].gif">

Now let's look at a sample template that correctly uses the database above to randomly choose 1 item from the list and display the results at the top of a page:

<html><body>
[search db=BannerAds.db&neAdNumberdata=0&max=1&AdNumbersdir=ra&AdNumbersort=1]
[founditems][interpret][BannerHTML][/interpret][/founditems]
[/search]
</body></html>

The results here are what we expected:

<img src="47.gif">

DOWNLOAD WEBDNA NOW!

Top Articles:

AWS Raw WebDNA LAMP-Plus WebServer

Amazon Web Services (AWS) README for Machine Image ID...

WebDNA Libraries

A list of available libraries for WebDNA...

Technical Change History

This Technical Change History provides a reverse chronological list of WebDNA changes...

F.A.Q

A compilation of some user's questions...

Download WebDNA Applications

WebDNA applications...

WebDNA reference

A list of all WebDNA instructions...

Related Readings:

[!]

Hides text...

[listmimeheaders]

Lists all the MIME header names and values sent from the remote browser...

DB encryption

Database Automatic Encryption (from WebDNA 8...

[clearlineitems]

Remove all line items from the specified shopping cart...

[listchars]

Breaks a string of text into separate characters...

[setheader]

Changes header values in a shopping cart...