Ignore that the code in the plugin is ridiculously simple because I'm after simple proof that I understand the process before moving on to writing top code (well I can dream).
Have read much documentation and whatever support questions I could find that shed light as well as asking previous questions and am more than certain that I understand what is happening as TWiki dynamically builds up web pages from TWiki variables. I have also, since February acheived reasonable proficiency in reading perldocs (and even in working out which perldoc to look in for x).
In most cases the TWiki variable is worked out by binding $_[0] to a substitution (s///) with the example line out of EmptyPlugin.pm
e.g. $_[0] =~ s/%TWikivariable%/$builtup variable/geom;
or $_[0] =~ s/%TWikivariable%/&_somesubroutine/geom;
I basically found Peter's response in HowToExecuteAScript to be more enlightening than half the documents I read (pithy examples I can cognate are a godsend). This prompted me to take a simple task and see if I understood the variable substitution process by replacing a TWiki variable (%TableFolderListing%) with a HTML table containing a display of folder contents with each file in it's own cell (I said that it was stupidly trivial code). MartinCleaver pointed out in my earlier question MyFirstPluginErrors that I had some syntax errors and that I missed a 1: at the end of my subroutine - he also pointed out the usefulness of the perl -c switch (been using it all week Martin, thanks again) and other than that his reaction to the plugin indicated that I understood the structure - excellent.
Not. Sadly I'm obviously one of the expletive deleted's on the planet as I can't get %TableFolderListing% to be translated into a table.
Steps I've taken so far: 1) Written the subroutine as a perlscript and got it working.
2) Got subroutine to run (thanks MC)
3) Written a seperate plugin (with accompanying txt file) that has following line in handleCommonTags $_[0] =~ s/%TableFolderListin%/&TableFolderListing/gm; to call and assign the results of the sub to the variable - didn't work.
4) Added the code as a sub (with the same line above) to the DefaultPlugin in case I'd stuffed up the plugin creation - no joy.
5) Back to basics, sod the subroutine, simply assign text to $variable and bind that variable to %TWikiVariable%. Still no joy.
Am left with wondering whether I've understood how the dynamic substitution takes place.
One thing to note is that the variable $TableFolderListing is in the following format
use strict;at the top. The pathologically simplest example is:
sub commonTagsHandler;
{
$_[0] =~ s/%MYVAR%/Var substituted/;
}
If properly initialized (it should list in TWiki.InstalledPlugins) the plugin will replace instances of %MYVAR% with the string "Var substituted".
Steve, it would be useful if you start gather all the snippets you find useful into a new topic so we can build a tutorial for the next user.
-- MartinCleaver - 13 Apr 2005
Yep, that ties in with my understanding of the substitution. And as well as use strict, I also use warnings and use diagnostics. The painful path is already being documented Martin, if only for my own amusement later on. I had to remove Plugin.NiceFolderDisplayPlugin from my list of successfully installed plugins for the Environment section above - that is to say, it shows up as successfully installed but doesn't expand the variable. -- SteveMayes - 14 Apr 2005 Update on TWiki.InstalledPlugins: Plugin.NiceFolderDisplayPlugin does indeed show up in 'Plugins defined' but when I look down to the table immediately below that there is an anomaly. (I'm assuming that this lower table shows which plugins have fired up which subroutines) Although Plugin.NiceFolderDisplayPlugin shows up in the row 'initPlugin' it doesn't show up in the commonTagsHandler row, excuse me whilst I delve further. -- SteveMayes - 14 Apr 2005 Not suprising, if that semicolon on the end of the
sub commonTagsHandler line is still there.
-- CrawfordCurrie - 14 Apr 2005
Dry, witty, pithy. You're either Canadian or British Crawford. ;-)You're also correct. Damn. -- SteveMayes - 14 Apr 2005 Whoops, sorry, I forgot to attach one of these:

-- CrawfordCurrie - 17 Apr 2005
| I | Attachment | History | Action | Size | Date | Who | Comment |
|---|---|---|---|---|---|---|---|
| |
FolderDisplayPlugin.pm | r1 | manage | 3.1 K | 2005-04-13 - 15:52 | UnknownUser | |
| |
hazard.gif | r1 | manage | 7.6 K | 2005-04-17 - 15:40 | UnknownUser |