http:images/logomed.png

StikiWeb Wiki - Samples.TrafficLight

Welcome: Visitor (Login)      Page History: Samples.TrafficLight


Main



 

Traffic Light

back to Samples


(@)

(@)

(@)

Click these links to turn red , turn green or turn yellow

How it works...

The traffic light is an orange backgrounded table with three rows of one column each. Each of the three cells contains an inlining link controlled by a variable that will refer to one of four child pages that present a light in a different color.

Red

(@)

Red

Yellow

(@)

Yellow

Green

(@)

Green

Off

(@)

Off

Each of the cells in the table (each of the 'lights' in the traffic signal) uses a variable to tell it which child page to display. The current values of these variables are shown in this table.

Variable

Current Value

red

.null.

yellow

.null.

green

.null.

A link that starts with an underscore character is 'relative' to the page containing the link. So, if the a page named FooBar contains the link string "_moo" it would refer to child page FooBar.Moo. (Note the capitalization of the first letter.) In our example, the link "_off" refers to page Off.

The links that change the lights color ( turn red , turn green and turn yellow ) are links to the current page that set the red, yellow and green variables.

The "turn red" link is coded as

[turn red | .(red=_red,yellow=_off,green=_off)]

where "turn red" is the link text, the dot is a refence to the currnet page, and the list of keyword=value pairs in parentheses gives the variables to set before displaying the page.

A word of warning about relative links: Bear in mind that relative links refer to children (or attachments) of the page that contains the link. If you copy text containing relative links from one page into another you need to make sure that any needed child pages or attachments exist relative to the new page. If you use a variable containing a relative link on two different pages it will refer to two different child pages or attachments. You should also bear in mind that there are no scoping rules for variables (they stay definied even after you leave the page that uses them) so you need to be careful of name-collisions.