(no commit message)
[openafs-wiki.git] / TWiki / IncludeTopicsAndWebPages.mdwn
1 # <a name="Include Topics and Web Pages Usi"></a><a name=" Include Topics and Web Pages Us"></a> Include Topics and Web Pages Using `%INCLUDE{...}%` Variable
2
3 Use the `%INCLUDE{...}%` variable to embed the content of another topic or web page inside a TWiki topic. The whole content or only parts of a page can be included. If needed, set a proxy server in [[TWikiPreferences]].
4
5 <div>
6   <ul>
7     <li><a href="#Syntax Example"> Syntax Example</a></li>
8     <li><a href="#Usage Examples"> Usage Examples</a><ul>
9         <li><a href="#1. Display regression test resul"> 1. Display regression test results in a TWiki page</a></li>
10         <li><a href="#2. Display Google's robot.txt fi"> 2. Display Google's robot.txt file</a></li>
11         <li><a href="#3. Display the current time in T"> 3. Display the current time in Tokyo in a TWiki page</a></li>
12         <li><a href="#4. Include a topic _MyTopic wit"> 4. Include a topic MyTopic with two parameters</a></li>
13         <li><a href="#5. Alert Box using Parameterized"> 5. Alert Box using Parameterized Include</a></li>
14       </ul>
15     </li>
16   </ul>
17 </div>
18
19 ## <a name="Syntax Example"></a> Syntax Example
20
21 `%INCLUDE{ "page" pattern="reg-exp" rev="2" warn="off" section="clients" PARAMETER1="value" PARAMETER2="Some value"}%`
22
23 The `pattern` parameter is optional and allows you to extract some parts of a web page. Specify a %SYSTEMWEB%.RegularExpression that scans from start (`'^'`) to end and contains the text you want to keep in parenthesis, e.g., `pattern="^.*?(from here.*?to here).*"`. You need to make sure that the integrity of a web page is not compromised; for example, if you include a table, make sure to include everything including the table end tag.
24
25 The example parameters PARAMETER1 and PARAMETER2 will be defined as a variable within the scope of the included topic. The example parameters shown will result in %PARAMETER1% and %PARAMETER2% being defined within the included topic.
26
27 [[VarINCLUDE]] explains the other parameters.
28
29 **_Note:_** All text of a topic is included unless it contains a `%STARTINCLUDE%` and `%STOPINCLUDE%`, or you specify a `section` parameter and/or a `pattern` parameter. A pattern will only search between `%STARTINCLUDE%` and `%STOPINCLUDE%`.
30
31 ## <a name="Usage Examples"></a> Usage Examples
32
33 ### <a name="1. Display regression test resul"></a> 1. Display regression test results in a TWiki page
34
35       <pre>
36       %INCLUDE{"http://domain/~qa/v1.1/REDTest.log.txt"}%
37       </pre>
38
39 ### <a name="2. Display Google&#39;s robot.txt fi"></a> 2. Display Google's robot.txt file
40
41       %INCLUDE{"http://www.google.com/robots.txt"}%
42
43 ### <a name="3. Display the current time in T"></a> 3. Display the current time in Tokyo in a TWiki page
44
45 - You type:
46   - <code>**Tokyo: %INCLUDE\{"http://TWiki.org/cgi-bin/xtra/tzdate?tz=Asia/Tokyo" pattern="^.\*&lt;\\!--tzdate:date--&gt;(.\*?)&lt;\\!--/tzdate:date--&gt;.\*"\}%**</code>
47 - You get:
48   - Tokyo:
49
50 ### <a name="4. Include a topic _MyTopic with"></a> 4. Include a topic MyTopic with two parameters
51
52 You include the topic with this line
53
54       %INCLUDE{ "MyTopic" BETTER="apples" WORSE="Oranges"}%
55
56 An example of a very simple MyTopic could contain
57
58        * I like %BETTER% better than %WORSE%.
59
60 The result would be
61
62 - I like apples better than oranges.
63
64 ### <a name="5. Alert Box using Parameterized"></a> 5. Alert Box using Parameterized Include
65
66 Create a topic called AlertBox with the following content:
67
68     -----
69     %STARTINCLUDE%
70     <div style="border-color:#FF9933; border-style:solid; border-width:thin; width:85%;  margin: 0 auto">
71     <table cellpadding="5" width="100%" cellspacing="0" cellpadding="12" border="0">
72     <tr bgcolor="#FFBB55">
73     <td valign="top" width="16"><img src="%ICONURL{warning}%" width="16" height="16" align="absmiddle" alt="" border="0"></td>
74     <td><b> %TITLE% </b></td>
75     </tr>
76     <tr bgcolor="#FFCC66">
77     <td>&nbsp;</td>
78     <td> %MESSAGE% </td>
79     </tr>
80     </table>
81     </div>
82     %STOPINCLUDE%
83     -----
84
85 Now you can write `%INCLUDE{ "AlertBox" TITLE="Alert" MESSAGE="This a test message" }%` to get this:
86
87 The `TITLE=""` and `MESSAGE=""` parameters are passed into the include. Using this approach, you can create a library of boxes in the %USERSWEB% web, such as %USERSWEB%.NoteBox, %USERSWEB%.InfoBox.
88
89 **_Related Topics:_** [[VarINCLUDE]], [[UserDocumentationCategory]]