summaryrefslogtreecommitdiff
path: root/TWiki/IncludeTopicsAndWebPages.mdwn
blob: 1390fce62907d17e4094172cc5481ea4f140c3e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
**Include Topics and Web Pages Using <code>**%INCLUDE\{...\}%**</code> Variable**

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.

%TOC%

## <a name="Syntax"> Syntax </a>

<code>**%INCLUDE\{"page" pattern="reg-exp"\}%**</code>

* <code>**"page"**</code>: <br /> The nameless parameter specifies the page to include. It is
  * The name of a topic located in the current web, i.e. <code>**%INCLUDE\{"WebNotify"\}%**</code>
  * A `Web.Topic` name specifying a topic in another web, i.e. <code>**%INCLUDE\{"%TWIKIWEB%.TWikiWebsTable"\}%**</code>
  * 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.

* <code>**pattern="reg-exp"**</code>: <br /> The **pattern** parameter is optional and allows you to extract some parts of a web page. Specify a %TWIKIWEB%.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.

**_Note:_** All text of a topic is included unless you specify <code>**%STARTINCLUDE%**</code>, <code>**%STOPINCLUDE%**</code> and/or a **pattern** parameter.

## <a name="Usage_Examples"> Usage Examples </a>

### <a name="1_Display_regression_test_result"> 1. Display regression test results in a TWiki page </a>

<pre>
  &amp;lt;pre&amp;gt;
  %<nop>INCLUDEURL{"http://domain/~qa/v1.1/REDTest.log.txt"}%
  &amp;lt;/pre&amp;gt;
</nop></pre>

### <a name="2_Display_Yahoo_s_robot_txt_file"> 2. Display Yahoo's robot.txt file </a>

* You type:
  * <code>**%INCLUDE\{"http://www.yahoo.com/robots.txt"\}%**</code><br />
* You get:

    %INCLUDE{"http://www.yahoo.com/robots.txt"}%

### <a name="3_Display_the_SUNW_stock_quote_i"> </a> 3. Display the SUNW stock quote in a TWiki page

* You type:
  * <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 />
* You get:
  * SUNW: %INCLUDE\{"http://finance.yahoo.com/q?s=SUNW&amp;d=v1&amp;o=t" pattern="^.\*?&gt;SUNW[^&lt;]+(.\*?)\\s+\\S+\\s+&lt;small.\*"\}%

### <a name="4_Display_the_temperature_in_San"> 4. Display the temperature in San Francisco </a>

* You type:
  * <code>**San Francisco: %INCLUDE\{"http://weather.yahoo.com/forecast/San\_Francisco\_CA\_US\_f.html" pattern="^.\*?([0-9]+\\&amp;ordm\\;F).\*"\}%**</code><br />
* You get:
  * San Francisco: %INCLUDE\{"http://weather.yahoo.com/forecast/San\_Francisco\_CA\_US\_f.html" pattern="^.\*?([0-9]+\\&amp;ordm\\;F).\*"\}%

See also other [[TWikiVariables]].

-- [[Main/PeterThoeny]] - 25 Jun 2001 <br />