Web Crossing


Introduction

Installation & Upgrade

Web Crossing Features

Customizing & Scripting

UniqueIDs, Full Paths & URL Codes

Basic Customization

Server-Side Scripting

Web Crossing Template Language (WCTL)

WCTL Code Examples

Server-Side Scripting: Web Crossing JavaScript (WCJS)

User & Access Issues

Data Organization & Management

Performance Issues

Appendix

Site Map

WCTL Examples
Creating an Ignore User Filter

Sometimes, just like in face-to-face life, community members get on each other's nerves. One powerful tool many sites use to help people stay out of each other's way is an Ignore User filter, sometimes known as a "bozofilter." What this does is let the user choose to ignore the posts of up to 5 different authors. When the user encounters a post by someone on their Ignore list, instead of seeing the post, they see a note stating that it's been ignored.

This filter is built to make it impossible for users to ignore their own posts or those of a host or the sysop. Hosts cannot ignore any posts in the area in which they have host privileges, and the sysop cannot ignore any posts anywhere.

We'll need to make changes to three macros in order to build this filter:


As with any macro customization, the process is to find the appropriate macros within the standard.tpl file in your webx directory on the server, place them in a separate text file you name webx.tpl, and edit them there. Upload webx.tpl to your webx directory, and reset the file cache in the Control Panel > Reset file cache to see your changes.

Editing editPreferences

First, find the editPreferences macro. The black code just below is existing editPreferences code. Find the correct lines, and insert the code in red in between. If you'd prefer to put the code elsewhere on the page, you may.

<tr><td colspan=2><b>Personal information</b> (optional):<br>
<textarea name=bio rows=8 cols=70 maxlength=24000 wrap=physical>%% userBio %%</textarea></td></tr>%%nop%%
<tr><td colspan=2><b>Your favorite URLs</b>
(optional, one per line, each URL may be followed by a space and a comment):<Br>
<textarea name=urls rows=10 cols=70 maxlength=24000>%% userUrlsRaw %% </textarea></td></tr>%%nop%%
%% if servePictures || serveInfoPictures %%
<tr><td colspan=2>%% use PictureInfo %%</td></tr>%%nop%%
%% endif %%

<tr><td colspan=2><hr>
<h3>Ignore Post List</h3>
<tr><td colspan=2>If there are users whose posts you prefer not to see, list them here. Enter <b>one user name per line</b> up to 5.<p>Note that you can not ignore the sysop or the host of an area even though you list them here. %% if userIsHostorSysop %% Hosts will see all user posts in the areas in which they are hosts, regardless of who is on their Ignore Post list.%% endif %%</td></tr>
<tr><td valign="top"><b>Users to ignore:</b></td>
<td><input name=user.bozo1 type=text size=15 maxlength=50 value="%% user.bozo1 %%"><Br>
<input name=user.bozo2 type=text size=15 maxlength=50 value="%% user.bozo2 %%"><Br>
<input name=user.bozo3 type=text size=15 maxlength=50 value="%% user.bozo3 %%"><Br>
<input name=user.bozo4 type=text size=15 maxlength=50 value="%% user.bozo4 %%"><Br>
<input name=user.bozo5 type=text size=15 maxlength=50 value="%% user.bozo5 %%"></td></tr>


<tr><td colspan=2><hr><h3>Settings</h3></td></tr>


  • This macro displays a sentence or two of instructions along with 5 form blanks where users can enter names for their personal Ignore list.
  • Most of the changes to this macro consist of standard HTML form fields within the existing table layout. The %% user.bozo1 %%, %% user.bozo2 %%, etc. are the names of the Web Crossing custom user fields we'll create when the user submits the form. These fields will hold the names of the individual Ignored users. Placing %% user.bozo1 %% into the value attribute of the form field ensures that the existing value will be shown to the user when he or she returns to Preferences another time.
  • The %% if userIsHostorSysop %% block in the instructions serves an extra line of instructions (up until the %% endif %% statement) to Hosts and Sysop, but not to regular users.

This produces the following HTML for a user who is not a Host or the Sysop.:

Figure 1 - Edited portion of editPreferences page

Ignore Post List - Preferences


Editing editedPreferences

Find the editedPreferences macro, and within it, locate these existing lines of code, in black. Once again, paste in the red code below at the proper location. If you'd rather have this display elsewhere on the page, you can do that instead.

<tr><td colspan=2><b>Personal information: </b><Br>%% userBio %%</td></tr>%%nop%%
<tr><td colspan=2><b>Your favorite URLs: </b><Br>%% userUrls %%</td></tr>%%nop%%

<tr><td valign="top"><b>Users on your Ignore Post list:</b></td><td>
%% user.bozo1 %%<Br>
%% user.bozo2 %%<Br>
%% user.bozo3 %%<Br>
%% user.bozo4 %%<Br>
%% user.bozo5 %%<Br></td></tr>%% nop %%


<tr><td colspan=2><b>%%nop%%
%% if userFolderSortBy oldestCreated%%
List items by date/time created, oldest first


  • These additions simply display the user's Ignored Post list in the page which is displayed after a user submits Preference changes


This produces the following HTML. Note that only one user has been defined so the other fields don't produce any names.

Figure 2 - Edited portion of editedPreferences page

Ignore Post List - edited Preferences


Editing messageListItem

This last addition goes into your messageListItem template, toward the top. This one must go in the designated spot or the filter won't work correctly.

%% If pathIsDeleted %%
     %% if siteShowDeleted %%
     %% spacing %%(Deleted message originally posted by %% authorName %% on %% itemDate %%)<Br clear=left>%%nop%%
     %% endif %%


%% else if !userIsHostorSysop && !author.userIsHostorSysop && authorName != userName && (user.bozo1 == authorName || user.bozo2 == authorName || user.bozo3 == authorName || user.bozo4 == authorName || user.bozo5 == authorName) %%
%% spacing %%(This message not displayed because <b>%% authorName %%</b> is on your Ignore Posts list. To change your Ignore Posts list go to <a href="%% urlBase %%25@%% certificate %%@%% location %%">Preferences</a>.)<Br clear=left>%% nop %%


%% else %%
%% if servePictures && userShowPictures %%
...

  • The statement beginning "else if" is really the meat of the filter. A translation for some of the symbols:
    ! "is not"
    != "is not equal to"
    || "or"
    && "and"
    == "is equal to"

    So, translating the code, we see it says:

    If the message has been deleted, deal with it that way,

    Otherwise if
    the user is not a host or sysop
    and
    the author is not a host or sysop
    and
    the author name is not the same as the user name
    and one of these is also true:

    user.bozo1 is the author
    or
    user.bozo2 is the author
    or
    user.bozo3 is the author
    or
    user.bozo4 is the author
    or
    user.bozo5 is the author
    Then display the Ignore text, with a link back to Preferences, instead of the actual message.

    Otherwise (i.e. if this convoluted logic statement doesn't evaluate as true), the macro goes on to display the message.

This produces the following HTML for an ignored message:

Figure 3 - Ignored message display

Ignore Post List - ignored post

Note: This macro does not explicitly check to see that users listed on the user's Preferences page actually exist in the database. It would be simple to add that check by adding a Preferences Process Filter, and check for the existence of the user name before submitting the form. If the user didn't exist, the form would be bounced back.

 

Resources

WCTL Concept Reference Page


A Non-Programmer's Guide to Web Crossing
by Sue Boettcher and Doug Lerner

© 2000 Web Crossing, Inc.