Technical References - [interpret]

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

numero = 260
interpreted = N
texte = [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    BannerHTML1           <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">
[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:

F.A.Q

A compilation of some user's questions...

Tips and Tricks

A list of user-submitted tips ...

WebDNA Modules

A list of the currently available modules...

WebDNA Libraries

A list of available libraries for WebDNA...

WebDNA reference

...

Technical Change History

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

Related Readings:

[unurl]

Changes text from URL-compatible characters to plain text...

[SQLresult]

...

[elapsedtime]

...

[copyfile]

Copy a file with the content you want on your webspace...

[table]

[table] allows you to quickly create a temporary 'in line' database that is local to the template and not part of the global database cache...

[array]

Array Operation...