b r a y d e n . o r g / Software

/ WebHome / TipsAndTricks / TWikiIncludeTricks

This Web


WebHome  
Topic List  
Web Statistics 

All Webs


Books
Main
Random
Software
TWiki  

brayden.org


Home
Monthly Digest
Today's Links
Resumé
Reading List
Books RSS
Random RSS
Software RSS

Other


Dale's Blog

currently-reading
TextDrive

Interesting uses of the TWiki INCLUDE directive

TWiki INCLUDE Directive

TWiki INCLUDE Directive

The INCLUDE directive is documented at IncludeTopicsAndWebPages. Here are the main ways to use it:

You can include one twiki topic within another. That's how I do the WebRss pages - the RSS feeds at this site and also most of the content at MonthlyDigest:

 % INCLUDE{"TWiki.WebRssBase"}%
 % INCLUDE{"Software.BeepProtocol"}% ... Software.BeepProtocol -- 25 Jul 2003

You can define what part of a twiki page will be included. You do this using the %STARTINCLUDE% and %STOPINCLUDE% directives on the included page.

When defining skin templates you can include one template within another, using the TMPL:INCLUDE directive:

 % TMPL:INCLUDE{"twiki.void"}%

Skin templates can also include a twiki topic as part of the skin output:

 % TMPL:DEF{"TopBar"}% % INCLUDE{"FlexibleSkinTopBar"}% %TMPL:END%

You can include an entire web page:

 % INCLUDE{"http://www.fvrl.org/events/index.cfm?listexpand=nav2053&buttontext=Book%20Sales"}%

You can include just part of a web page, by setting to/from patterns:

 % INCLUDE{"http://www.wrh.noaa.gov/cgi-bin/wrhq/TotalForecast.csh?TotalForecast+Portland+WA+039"
   pattern="^.*?(<table BORDER=0.*?<td>=).*"}% </font></font></table></table>

A Patch to Net.pm

If including a URL takes a long time it may be because of a buglet in the TWiki Net.pm module. Specifically, the URL request should contain connection:close in the HTTP header. This will force the connection to close rather than wait for it to timeout. At about line 60 change as follows:

   my $req = "GET $theUrl HTTP/1.1\r\n$theHeader\r\n\r\n";

to

   my $req = "GET $theUrl HTTP/1.1\r\n$theHeader\r\nConnection: close\r\n\r\n";

Thanks to Paul:Main/WebHome for pointing this out. See also TWiki:Codev/IncludeHTMLTakesLongTime.

-- DaleBrayden - 31 Jul 2003

 
 
Current Rev: r1.1 - 03 Dec 2005 - 18:08 GMT - DaleBrayden, Revision History:Diffs | r1.1
© 2003-2011 by the contributing authors.