Version 3.1 User's Guide |
|
Advanced Techniques |
Previous |
Next Contents |
Now that the basics of using NetCloak's dynamic page commands have been covered, this section will continue with some more advanced techniques.
The Introduction introduced the concept that the SHOW command will never cause a HIDE and vice-versa. For instance,
<SHOW_DOMAIN BEGINS 123.45>
will show text following it for those in the domain "123.45", but it will not hide text from those outside the domain. To do this, you must precede the SHOW command with an unconditional HIDE. To show only to clients in the domain 123.45, use this instead:
<HIDE><SHOW_DOMAIN BEGINS 123.45>
Think of the text of your document as a stream of text flowing through a faucet. When you use a conditional SHOW command, you are saying "turn the faucet on if this is true" but you are not saying "turn the faucet off if it is not true". The same rule applies to HIDE.
This allows using the commands in a cumulative way. The cumulative effect is best seen by an example:
"some.domain".
<SHOW>
This last line can be seen by everyone.
If we had wanted the sixth line to be hidden ONLY from "another.domain", the HTML would have been:
<SHOW>
This last line can be seen by everyone.
The extra SHOW command turns the HTML on before the HIDE command turns it off for the desired users. This can get a little confusing, but there is a simple rule.
When you want to specify "Hide only from …", use:
<SHOW><HIDE …>
And when you want to specify "Show only to…", use:
<HIDE><SHOW …>
This is very important, as the next example shows:
<SHOW>
This line is visible all the time!
<SHOW_DAY BEGINS SAT SUN>
This line is ALSO visible to the world.
In this example, since everyone could already view the HTML text, SHOW_DAY didn't do anything. To do what we want, which is to show the line only on the weekends, this example should be:
<SHOW>
This line is shown all the time!
<HIDE><SHOW_DAY BEGINS SAT SUN>
This line is visible ONLY on the weekend.
<SHOW>
By hiding first, we block access from everyone and then let people see the text ONLY when we want.
Why does NetCloak work like this?
Because, despite the fact that it takes a little getting used to, it gives you a lot more flexibility. For example, let's say you wanted to have a section of your document available only to your company all the time. The rest of the world could see the section during non-business hours only. In this case, you could do this:
<SHOW>
This line is always available to everyone
<HIDE>
<SHOW_DOMAIN IS my.local.domain>
<SHOW_DAY BEGINS SAT SUN>
<SHOW_TIME GT= 19:00>
<SHOW_TIME LT 06:00>
This line is available to my local users all the time, and to the rest of the world during off hours.
<SHOW>
This example first hides the HTML text, then shows it for each specific case.
As you've seen, you can show and hide portions of your pages based on a wide range of variables within NetCloak. This gives you a great deal of flexibility and you can create fairly complex conditions in which each part of a page will be visible. You can also negate the comparison in conditional SHOW and HIDE commands which allows you to show or hide in all cases except when the condition is true.
For example, assume you wanted to have a portion of your page visible during the normal business week, Monday through Friday. You could write:
<HIDE>
<SHOW_DAY BEGINS MON TUE WED THU FRI>
This text is visible during the week only.
But there is another way to make this same statement. Instead of saying "show text on Monday, Tuesday, Wednesday, Thursday, and Friday" (as we did above), you could say "show text on all days except Saturday and Sunday". To do this, you would use:
<HIDE><SHOW_DAY# BEGINS SAT SUN>
This text is visible during the week only.
In reality, this isn't really much easier, at least in this example. But what if you wanted to show text based on SHOW_DOMAIN to all users except those at a certain address. You certainly wouldn't want to list every domain on the Internet, so <SHOW_DOMAIN# 192.1.2.3> could be very handy when you want to show a section of your page to everyone except those at the address 192.1.2.3.
Of course, you could, in many cases, also use the HIDE commands instead. For example, the "192.1.2.3" example could have been written as:
<SHOW><HIDE_DOMAIN 192.1.2.3>
The real power of negating comparisons to make "except" statements comes into play when combining commands.
When building more complicated conditionals, using HIDE in place of SHOW except is no longer an option. Remember that SHOW and HIDE are fundamentally different in that SHOW will never "hide" text, and HIDE will never cause text to be seen. So, if we wanted to have a portion of text visible only to Joe from domain 192.1.x.x, we could not use:
<HIDE><SHOW_USERNAME IS JOE>
<SHOW_DOMAIN BEGINS 192.1.>
This text would be visible to "JOE" AND to users coming from "192.1"!
In this case, as long as the user's name was Joe, it wouldn't matter what their domain was, because the <SHOW_DOMAIN 192.1.> command would never turn the faucet off. Joe's all over the Internet would have access to the text. Similarly, anyone in the domain 192.1 would also see the text, no matter what their name.
Instead, you could use the except variation to achieve the desired effect:
<HIDE><SHOW_USERNAME IS JOE>
<HIDE_DOMAIN# BEGINS 192.1.>
This is what we wanted! Only Joe can see this, and only if he's at 192.1.
The first part of this is simple enough… Hide text, then let Joe see it again. The command <HIDE_DOMAIN# BEGINS 192.1.> (note the "#" character) is really saying "OK, text is on, so it's Joe. Now hide the text except when he is in the '192.1' domain".
Another common use for this technique is with username and password commands. These commands each work on the username or password, but not both. To show based on the username and password, use:
<HIDE><SHOW_USERNAME IS clarus>
<HIDE_PASSWORD# IS moof>
The SHOW_USERNAME will only show HTML following it if the username is "clarus", and the HIDE_PASSWORD# will hide it again except when the password is also "moof". This results in the HTML following the show/hide-except commands being shown only when the username and password are both correct.
You've no doubt noticed by now that there is usually more than one way to achieve the same result, by converting SHOWs to HIDEs and then negating the comparison operator, or by using an "except" variation of a command, or by using a different operator. For instance, a "LT" operator is identical to a "#GT=" operator. You may use whichever combination of comparison operators and commands you feel most comfortable with that achieves the desired results.
Finally, you can combine the power of NetCloak commands in more interesting ways, by nesting any INSERT command as a parameter inside another NetCloak command. When nesting commands, the nested INSERT command must not be enclosed in double-quotes (otherwise, it is treated as plain text). Here are some examples of nested commands:
Create a counter with the name of the current URL:
<INSERT_COUNT <INSERT_THISURL>>
Maintain a count of hits from each distinct browser type:
<INSERT_COUNT <INSERT_CLIENT>>
Redirect to a user-selected URL:
<REDIRECT <INSERT_VARIABLE selectedURL>>
Insert a macro file based on the current date
<SET_LOCAL todaysMacro = "/DatedMacros/" & <INSERT_DATE SHORT>>
<MACRO <INSERT_LOCAL todaysMacro>>
Redirect to a selected page in a certain folder:
<REDIRECT /newPath/<INSERT_VARIABLE selectedPage>>
Using Nested INSERT commands can be tricky, and we recommend only using them when you are very familiar with how NetCloak works and the commands being used.
Copyright © 1996-2000 Maxum Development Corporation http://www.maxum.com/ |
Previous |
Next Contents |