none
[openafs-wiki.git] / TWiki / IncludeTopicsAndWebPages.mdwn
1 **Include Topics and Web Pages Using <code>**%INCLUDE\{...\}%**</code> Variable**
2
3 Use the <code>**%INCLUDE\{...\}%**</code> variable to embed the content of another topic or web page inside a %WIKITOOLNAME% topic. The whole content or only parts of a page can be included.
4
5 <div>
6   <ul>
7     <li><a href="#Syntax"> Syntax</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 Yahoo's robot.txt fil"> 2. Display Yahoo's robot.txt file</a></li>
11         <li><a href="#3. Display the SUNW stock quote"> 3. Display the SUNW stock quote in a TWiki page</a></li>
12         <li><a href="#4. Display the temperature in Sa"> 4. Display the temperature in San Francisco</a></li>
13       </ul>
14     </li>
15   </ul>
16 </div>
17
18 ## <a name="Syntax"></a> Syntax
19
20 <code>**%INCLUDE\{"page" pattern="reg-exp"\}%**</code>
21
22 - <code>**"page"**</code>: <br /> The nameless parameter specifies the page to include. It is
23   - The name of a topic located in the current web, i.e. <code>**%INCLUDE\{"WebNotify"\}%**</code>
24   - A `Web.Topic` name specifying a topic in another web, i.e. <code>**%INCLUDE\{"TWiki.TWikiWebsTable"\}%**</code>
25   - A full qualified URL with <code>**http**</code> protocol, domain name and optional port number, i.e. <code>**%INCLUDE\{"http://twiki.org:80/index.html"\}%**</code>. Supported content types are <code>**text/html**</code> and <code>**text/plain**</code>. The full page is included by default, but the HTML header and scripts are stripped in case it is a web page.
26
27 - <code>**pattern="reg-exp"**</code>: <br /> The **pattern** parameter is optional and allows you to extract some parts of a web page. Specify a [[RegularExpression]] that scans from start (`'^'`) to end and contains the text you want to keep in parenthesis, i.e. <code>**pattern="^.\*?(from here.\*?to here).\*"**</code>. You need to make sure that the integrity of a web page is not compromised, i.e. if you include a table make sure to include everything including the table end tag.
28
29 **_Note:_** All text of a topic is included unless you specify <code>**%STARTINCLUDE%**</code>, <code>**%STOPINCLUDE%**</code> and/or a **pattern** parameter.
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       %INCLUDEURL{"http://domain/~qa/v1.1/REDTest.log.txt"}%
37       </pre>
38
39 ### <a name="2. Display Yahoo&#39;s robot.txt fil"></a> 2. Display Yahoo's robot.txt file
40
41 - You type:
42   - <code>**%INCLUDE\{"http://www.yahoo.com/robots.txt"\}%**</code><br />
43 - You get:
44
45     %INCLUDE{"http://www.yahoo.com/robots.txt"}%
46
47 ### <a name="3. Display the SUNW stock quote"></a><a name="3. Display the SUNW stock quote "></a> 3. Display the SUNW stock quote in a TWiki page
48
49 - You type:
50   - <code>**SUNW: %INCLUDE\{"http://finance.yahoo.com/q?s=SUNW&amp;d=v1&amp;o=t" pattern="^.\*?&gt;SUNW&lt;/a&gt;[^&lt;]+(.\*?)\\s+\\S+\\s+&lt;small.\*"\}%**</code><br />
51 - You get:
52   - SUNW:
53
54 ### <a name="4. Display the temperature in Sa"></a> 4. Display the temperature in San Francisco
55
56 - You type:
57   - <code>**San Francisco: %INCLUDE\{"http://weather.yahoo.com/forecast/San\_Francisco\_CA\_US\_f.html" pattern="^.\*?([0-9]+\\&amp;ordm\\;F).\*"\}%**</code><br />
58 - You get:
59   - San Francisco:
60
61 See also other [[TWikiVariables]].
62
63 -- [[PeterThoeny]] - 25 Jun 2001 <br />