WCTL
Server-side Scripting
An
Introduction to WCTL
Introduction
User and Author Variables
Other Variable Types
Troubleshooting
Resources
Next Section
Introduction
In the
previous section, you created
a simple script and placed it in a folder header. The script contained
the expression %% user.userName %%. When the folder header
was displayed, %% user.userName %% was automatically replaced
by the logged in user's user name. This expression, including
the surrounding double-percent marks, was written in the Web
Crossing Template Language (WCTL).
WCTL
is Web Crossing's traditional scripting language. Almost all you
see in Web Crossing - folders, discussions, messages, the login
form, the registration form, the form in which you set user preferences,
etc., are defined as templates which are written as a combination
of standard HTML mixed with WCTL. You can modify these templates
to gain almost 100% control over your Web Crossing conference.
WCTL
is a full programming language, with variables and conditional
structures, file I/O, filters, email abilities and many other
features. Using WCTL you can modify not only the appearance
of your Web Crossing forums, but also the actions taken
when users access your forums. You can even use WCTL instead of
ordinary CGI (Common Gateway Interface) programs to do things
like provide hit counters for your Web Crossing pages and form
handling, such as form to email handlers. These are easily accomplished
using WCTL.
Before
we start in on writing full templates, let's look some more at
the expression %% user.userName %% and understand all the
parts of this expression. Understanding the syntax of WCTL will
help reduce your learning curve and get you started with your
own customization more quickly.
User
and Author Variables
All WCTL
expressions are delimited by double-percent marks:
%% wctl expression %%
The contents
of a WCTL expression are evaluated and mixed in with the rest
of your HTML to create a web page which is sent to the user's
browser.
For example,
as we saw in the previous section,
%% user.userName %%
became
substituted by the current (accessing) user's user name. If the
user's name was Doug, then
Hello, %% user.userName %%.
appeared
as
- Hello,
Doug.
to the
user.
Note:
Spaces in WCTL expressions (between the percent marks) are
ignored. For example, %% user.userName %% and %%user.userName%%
are evaluated the same way. Extra spaces are not added to
the HTML created by Web Crossing. You can include spaces
in your expressions to make your WCTL easier to read.
|
In between
the percent-marks the WCTL expression user.userName is a variable
(a place holder for values) with two parts
- user
(before the period)
- userName
(after the period)
The word
user (before the period) is the type of variable
and the word userName (which follows the period) is the
name of the variable (or, as we often call it, the property).
The userName property is a standard Web Crossing property belonging
to all Web Crossing registered users. Each user has a unique userName
that is set at registration time.
There
are various standard user properties such as userEmail
(the email address set when a user is registered) and user2ndLine
(the 2nd profile line user's can set when editing their preferences).
Using
WCTL you can also create your own customized user properties (such
as telephone number, sex, age, address, etc.) and add these properties
to the Web Crossing database. Customized user properties are stored
in the Web Crossing database and can be used just like other properties;
you can use them in WCTL expressions and use them for searches,
etc. We will see how to add customized user properties later on.
The user
type refers to "the registered user currently accessing Web Crossing."
In other words, if a user opens a Web Crossing forum and WCTL
in the page contains %% user.userName %%, the accessing user sees
his or her own name.
Another
type of variable - the author type - refers to the author
(the person who created a message or any other person being referred
to besides yourself) of the location being looked at. For example,
when you see a Web Crossing message written by somebody, the underlying
WCTL to display the author of that message is not %% user.userName
%% it is %% author.userName %%.
Perhaps
the most common mistake that WCTL beginners make is confusing
user and author variable types. Just remember - a user
variable refers to the actual user who is accessing and looking
at the conference. An author variable refers to the other
users - people who wrote messages, for example. We will be returning
to this important point again and again.
To clarify
the difference between user and author variables, try this simple
test.
- Log
in as a test user under a different name other than sysop.
- Create
a folder anywhere on your system.
- Log
back in as sysop and Edit the folder you just created.
- In
the folder header add the following WCTL:
The author of this folder is %% author.userName %%.
<BR>
You are %% user.userName %%. <BR>
After
you have saved the changes to the header, go back and open the
folder. You will see that the first line shows the name of the
author of the folder - the test user you created. The second line
shows your name. Think back on this example if you ever get confused
by the difference between user and author variables.
Other
variable types
In addition
to user and author variables, WCTL also has other variable types.
We will be referring to these types as needed in subsequent sections.
The following table summarizes the various variable types:
Variable
type |
Meaning
|
untyped
(example: myMessage)
|
If
no type is specified, the variable is considered a local
variable. This variable is useful in macros as temporary
place holders for values. Local variables exist only during
the current execution of a macro and are not stored in the
Web Crossing database.
|
user
(example: user.userName)
|
A
user variable refers to the currently accessing user. You
can add new user properties whenever you want and the values
will get saved in the database.
|
author
(example: author.userName)
|
An
author variable refers to the author of the current location
or any third person whose properties you are changing (for
example, if you change a user's preferences via the Control
Panel). These values are also saved in the database.
|
path
(example: path.title)
|
A
path variable refers to the current location (top level,
folder, discussion, message, chat room or link). You can
add new path variables whenever you want and these values
are also saved in the database.
|
site
(example: site.totalVisitors)
|
A
site variable is a global variable that can be referenced
from anywhere. It is stored in the database and can be used
at any time. You can add as many site variables as you want.
|
session
(example: session.count)
|
A
session variable is a temporary variable that lasts only
during a user's access session. Each session variable is
assigned to the currently accessing user and is tracked
by following the user's certificate. The user does not have
to be a registered user. Session variable are not saved
in the database. You can use session variables to track
a visitors page views, keep track of a user's shopping cart,
etc.
|
The next
section will use some of these variable types and show you
more about WCTL syntax and usage.
Troubleshooting
I tried
the example above, but when I look at the header all I see is
the WCTL itself, with all the double-percent marks. What am I
doing wrong?
- Make
sure you have turned on WCTL evaluation in the Control
Panels > General Settings:
Resources
Web
Crossing FAQ:
Sysop
docs:
WCTL
Concept Reference Page
Web
Crossing Tech Support Forum
Developer
Center
WebX
Harbor
|