none
[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       </ul>
14     </li>
15   </ul>
16 </div>
17
18 ## <a name="Syntax Example"></a> Syntax Example
19
20 `%INCLUDE{ "page" pattern="reg-exp" rev="2" warn="off" section="clients" PARAMETER1="value" PARAMETER2="Some value"}%`
21
22 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.
23
24 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.
25
26 [[VarINCLUDE]] explains the other parameters.
27
28 **_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%`.
29
30 ## <a name="Usage Examples"></a> Usage Examples
31
32 ### <a name="1. Display regression test resul"></a> 1. Display regression test results in a TWiki page
33
34       <pre>
35       %INCLUDE{"http://domain/~qa/v1.1/REDTest.log.txt"}%
36       </pre>
37
38 ### <a name="2. Display Google&#39;s robot.txt fi"></a> 2. Display Google's robot.txt file
39
40       %INCLUDE{"http://www.google.com/robots.txt"}%
41
42 ### <a name="3. Display the current time in T"></a> 3. Display the current time in Tokyo in a TWiki page
43
44 - You type:
45   - <code>**Tokyo: %INCLUDE\{"http://TWiki.org/cgi-bin/xtra/tzdate?tz=Asia/Tokyo" pattern="^.\*&lt;\\!--tzdate:date--&gt;(.\*?)&lt;\\!--/tzdate:date--&gt;.\*"\}%**</code>
46 - You get:
47   - Tokyo:
48
49 ### <a name="4. Include a topic _MyTopic with"></a> 4. Include a topic MyTopic with two parameters
50
51 You include the topic with this line
52
53       %INCLUDE{ "MyTopic" BETTER="apples" WORSE="Oranges"}%
54
55 An example of a very simple MyTopic could contain
56
57        * I like %BETTER% better than %WORSE%.
58
59 The result would be
60
61 - I like apples better than oranges.
62
63 **_Related Topics:_** [[VarINCLUDE]], [[UserDocumentationCategory]]