data/TWiki/IncludeTopicsAndWebPages.txt
author Colas Nahaboo <colas@nahaboo.net>
Sat, 26 Jan 2008 15:50:53 +0100
changeset 0 414e01d06fd5
permissions -rw-r--r--
RELEASE 4.2.0 freetown
     1 %META:TOPICINFO{author="TWikiContributor" date="1111929255" format="1.0" version="10"}%
     2 ---+!! Include Topics and Web Pages Using =%<nop>INCLUDE{...}%= Variable
     3 
     4 Use the =%<nop>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 %WIKIPREFSTOPIC%.
     5 
     6 %TOC%
     7 
     8 ---++ Syntax Example
     9 
    10 =%<nop>INCLUDE{ "page" pattern="reg-exp" rev="2" warn="off" section="clients" PARAMETER1="value" PARAMETER2="Some value"}%=
    11 
    12 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.
    13 
    14 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.
    15 
    16 VarINCLUDE explains the other parameters.
    17 
    18 __Note:__ All text of a topic is included unless it contains a =%<nop>STARTINCLUDE%= and =%<nop>STOPINCLUDE%=, or you specify a =section= parameter and/or a =pattern= parameter. A pattern will only search between =%<nop>STARTINCLUDE%= and =%<nop>STOPINCLUDE%=.
    19 
    20 ---++ Usage Examples
    21 
    22 ---+++ 1. Display regression test results in a TWiki page
    23 <pre>
    24   &lt;pre&gt;
    25   %<nop>INCLUDE{"http://domain/~qa/v1.1/REDTest.log.txt"}%
    26   &lt;/pre&gt;
    27 </pre>
    28 
    29 ---+++ 2. Display Google's robot.txt file
    30 
    31 <pre>
    32   %<nop>INCLUDE{"http://www.google.com/robots.txt"}%
    33 </pre>
    34 
    35 ---+++ 3. Display the current time in Tokyo in a TWiki page
    36 
    37    * You type:
    38       * ==Tokyo: %<nop>INCLUDE{"http://TWiki.org/cgi-bin/xtra/tzdate?tz=Asia/Tokyo" pattern="^.*&lt;\!--tzdate:date--&gt;(.*?)&lt;\!--/tzdate:date--&gt;.*"}%==
    39    * You get:
    40       * Tokyo: %INCLUDE{"http://TWiki.org/cgi-bin/xtra/tzdate?tz=Asia/Tokyo" pattern="^.*<\!--tzdate:date-->(.*?)<\!--/tzdate:date-->.*"}%
    41 
    42 ---+++ 4. Include a topic !MyTopic with two parameters
    43 
    44 You include the topic with this line
    45 <verbatim>
    46   %INCLUDE{ "MyTopic" BETTER="apples" WORSE="Oranges"}%
    47 </verbatim>
    48 
    49 An example of a very simple !MyTopic could contain
    50 
    51 <verbatim>
    52    * I like %BETTER% better than %WORSE%.
    53 </verbatim> 
    54 
    55 The result would be
    56 
    57    * I like apples better than oranges.
    58 
    59 __Related Topics:__ VarINCLUDE, UserDocumentationCategory
    60