This section discusses the syntax in .htx files.
The <%begindetail%>
and <%enddetail%>
tags surround a section of the HTML extension file in which the results of the search will be merged. The section will be interpreted once for each record matching the query on the page. Within the section, the column names delimited with <%
and %>
are used to mark the position of the returned data from the query. There can be only one detail section in the HTML extension file.
For example:
<dl> <%begindetail%><p> <dt> <%CiCurrentRecordNumber%>. <b><a href="<%vpath%>"><%filename%></a></b> <dd> <b><i>Abstract: </i></b><%characterization%><br> <font size=-1> - size <%size%> bytes - <%write%> GMT</font> <%enddetail%></dl>
This query does the following:
Note If there are no records returned from the query, the <%begindetail%>
section will be skipped.
HTML extension files can contain conditional logic with an if-then-else statement to control how the Web page is constructed. For example, one common usage is to insert a condition to display a header for the query on the first row within a <%begindetail%>
section; but if there are no records returned by the query, to display the text Sorry, no authors had YTD sales greater than %sales%
. By using the <%if%>
statement and a built-in variable called CiLastRecordNumber you can tailor the output so that the error message is printed when no records are returned. Here is an example showing the use of the <%if%>
statement.
<%begindetail%> <%if CiCurrentRecordNumber EQ 1%> Query results: <B>Author YTD Sales<BR></B> <%endif%> <%au_lname%>$<%ytd_sales%> <%enddetail%> <P> <%if CiLastRecordNumber EQ 0%> <I><B>Sorry, no authors had YTD sales greater than </I><%sales%>.</B> <P> <%else%> <HR> <I> The Web page you see here was created by merging the results of the Content query with the template file Sample.htx. <P> The merge was done by the Microsoft Index Server and the results were returned to this Web browser by the Microsoft Internet Information Server. </I> <%endif%> </BODY> </HTML>
The general syntax is:
<%if condition%> HTML text [ <%else%> HTML text ] <%endif%>
where condition is of the form: value1 operator value2 and operator can be one of the following:
value1 IsTypeEq value2
value1 IsTypeEq const1
const1 IsTypeEq value1
For example, if a variable is of type currency (VT_CY) its type is 6. Type numbers are defined in the ActiveX specification. A valid .htx comparison would be:
<%if propName IsTypeEq 6%>Variable is of type currency <%else%>Variable is NOT type currency <%endif%>
This operator is especially useful to check for type VT_EMPTY, an empty property.
The operands value1 and value2 can be column names, one of the built-in variables, an HTTP variable name (see HTTP
Variables), or a constant. When used in an <%if%>
statement, values are not delimited with <%
and %>
. For example, to do special processing on author name Green, use the condition:
<FORM ACTION="<%HTTP_SCRIPT_NAME%>?" METHOD="POST"> <%if au_lname EQ "Green"%> this guy is green! <%endif%> <%enddetail%>
The <%
if%>
statement can also be used to do special processing based on information from HTTP variables. For example,
to format a page differently based on the type of client Web browser you could include the following in the HTML extension
file.
<%if HTTP_USER_AGENT contains "Mozilla"%> client supports advanced HTML features <%else%> client is <%HTTP_USER_AGENT%> <%endif%>
Property types VT_FILETIME and VT_DATE can be compared within <%if%>
statements. Use the following format:
<%if fileTime eq "yyyy/mm/dd hh:mm:ss:iii"%>File times are identical <%endif%>
The time must be enclosed in quotes. The year must be a four-digit number (for example, 1996, not 96), and slashes and colons are required.
yyyy = year
mm = month ( 1=January, 12=December, and so on)
dd = day of month ( 1 - 31)
hh = hour of the day in 24-hour format (optional)
mm = minutes (optional)
ss = seconds (optional)
iii = milliseconds (optional)
For example:
<%if write le "1996/07/21 17:22:11:333"%>File times are identical <%endif%>
The <%EscapeHTML%>
, <%EscapeURL%>
, and <%EscapeRAW%>
keywords can be used to affect the formatting of output strings. These are typically used with variables such as CiRestriction, or CiScope when used in a form or in an anchor.
The output of variables is normally suitable for HTML format. The preceding keywords affect the output format so that the variable can be used correctly in different contexts. The form of the construct is:
<%EscapeHTML variable%> or <%EscapeURL variable%> or <%EscapeRAW variable%>
where variable is any parameter or variable that could be used in the HTTP Extension file. Constant values can also be used, as in, <%EscapeURL /scripts/query.idq%>
.
<%EscapeHTML%>
(the default formatting) is used to escape characters that are meaningful in HTML. For example, the symbol > will appear as >
.
<%EscapeURL%>
is used to do standard escaping for strings that will be URLs (as in the HREF tag of an anchor). For example, the string @size > 10000
; will appear as %40size+%3E+10000
.
<%EscapeRAW%>
is used when no escaping should be done. This might be the case for a variable that is being used as the value of a form variable, or to have the value of a variable that contains HTML code to be interpreted correctly.
The <%include%>
keyword can interpolate the contents of a file into the .htx file. The syntax of the construct is
<%include filename%>
where filename is the name of the file to be included. The file is named with a full virtual path name, and HTML extension constructs are interpreted if found in the file. File includes can be nested, but the total number of include files cannot exceed 31.
© 1997 by Microsoft Corporation. All rights reserved.
file: /Techref/language/asp/ix/ixhtxsyn.htm, 11KB, , updated: 1997/9/29 02:23, local time: 2024/12/27 23:33,
3.148.105.127:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://massmind.org/techref/language/asp/ix/ixhtxsyn.htm"> Microsoft Index Server: Syntax in HTML Extension Files</A> |
Did you find what you needed? |
Welcome to massmind.org! |
Welcome to massmind.org! |
.