Attach Content Plugin
Saves dynamic topic text to an attachment.
This plugin puts any text between a
%STARTATTACH{"filename"}% and
%ENDATTACH% into an attachment with the given filename.
Pass filename, topic, web or comment as parameters.
The current version only refreshes the attachment when the topic is saved. Obviously this means that the attachment can get out of synch if, for example, it explicitly or implicitly refers to other topics.
This plugin is written specifically to be able to put css into topic(s) and still be able to have efficient stylesheets: i.e., without the overhead of TWiki processing. The feature can be used for many other things where you want TWiki to generate a plain text file a smart way.
For example: write a
SEARCH in a topic and save the search results to an XML file. The XML data can be used for efficient look-up.
Write:
%STARTATTACH{"filename"}%
content-to-be-saved
%ENDATTACH%
You can pass a number of parameters:
Parameters
|
|
| Parameter |
Description |
Default |
Example |
topic |
Topic to save the attachment to. |
none (the current topic is used) |
topic="WebHome" |
web |
Web where the save topic is located. |
none (the current Web is used) |
web="Main" |
comment |
Attachment comment text. |
the default ATTACHCONTENTCOMMENT text (see Plugin Settings below) |
comment="User data as of %DATE%" |
hide |
Use hide="on" to hide the attachment in normal topic view. |
off |
hide="on" |
keeppars |
Keep paragraph <p /> tags, <nop> tags, and square bracket type links |
The default KEEPPARS setting (see Plugin Settings below) |
keeppars="on" |
|
|
|
Creating a color scheme
See:
PatternSkinColorSettings. This topic uses AttachContentPlugin to write a CSS file for colors. Color values are set dynamically in the topic. On topic save the CSS file is attached to the topic and can be referred to using variable
USERCOLORSURL.
User data XML
Update user data XML
%STARTATTACH{"userdata.xml" comment="User data as of %DATE%"}%
<?xml version="1.0" encoding="ISO-8859-1"?>
<users>
%SEARCH{ "[F]irstName.*value=.*()" web="%MAINWEB%" type="regex" nonoise="on" excludetopic="UserForm,TWikiContributor,TWikiGuest,UnknownUser" format="<user><firstname><![CDATA[$formfield(FirstName)]]></firstname><lastname><![CDATA[$formfield(LastName)]]></lastname><url><![CDATA[%SCRIPTURL{view}%/%WEB%/$topic]]></url></user>" }%
</users>
%ENDATTACH%
Plugin settings are stored as preferences variables. To reference a plugin setting write
%<plugin>_<setting>%, i.e.
%CACHECONTENTPLUGIN_SHORTDESCRIPTION%
- One line description, is shown in the TextFormattingRules topic:
- Set SHORTDESCRIPTION = Saves dynamic topic text to an attachment
- Debug plugin: (See output in
data/debug.txt)
- Keep paragraph <p /> tags, <nop> tags, and square bracket type links:
- The default comment text:
- Set ATTACHCONTENTCOMMENT = Generated by AttachContentPlugin
Note: You do not need to install anything on the browser to use this plugin. The following instructions are for the administrator who installs the plugin on the server where TWiki is running.
- Download the ZIP file from the Plugin web (see below)
- Unzip
AttachContentPlugin.zip in your twiki installation directory. Content:
|
|
| File: |
Description: |
data/TWiki/AttachContentPlugin.txt |
Plugin topic |
data/TWiki/AttachContentPlugin.txt,v |
Plugin topic repository |
lib/TWiki/Plugins/AttachContentPlugin.pm |
Plugin Perl module |
|
|
|
- Test if the installation was successful: Update user data XML to see if an attachment is created/updated
Related Topics: TWikiPreferences,
TWikiPlugins