My use case: create a custom view template with a customized list of attachments (pictures only, in fact). I want to achieve this without
TWiki:Plugins/FileListPlugin
.
This does not work: only the default attachment table is displayed, and writing
TMPL:DEFs to override the defs in
attachtables does not work.
Attach.pm reads (hard-coded) template
attachtables.
I have a solution that involves 2 changes:
1. Pass a template attribute to META
For instance:
%META{"attachments" template="%TEMPLATE%"}%
This would need 2 lines changed in
Attach.pm:
@@ -81,12 +81,13 @@
my $showAttr = $showAll ? 'h' : '';
my $A = ( $showAttr ) ? ':A' : '';
my $title = $attrs->{title} || '';
+ my $tmplname = $attrs->{template} || 'attachtables';
my @attachments = $meta->find( 'FILEATTACHMENT' );
return '' unless @attachments;
my $templates = $this->{session}->{templates};
- $templates->readTemplate('attachtables');
+ $templates->readTemplate($tmplname);
my $rows = '';
my $row = $templates->expandTemplate('ATTACH:files:row'.$A);
Actually it would be easy to implement the functionality of FileListPlugin by allowing to pass
topic,
web,
filter and
format parameters to
%META{"attachments"}%. Plus the view permissions check of course. But we can save that for later, but it will be important for
TWiki:Codev/ImproveAttachmentHandling
.
2. Make sure that attachtables are in its own file
My wrong. I have put in attachtables:
%TMPL:INCLUDE{"attach"}%
and this now causes the complete attach template to get included in the view template. Changing back is a minor change, but translation files need to be updated as well.
#: twikiplugins/PatternSkin/templates/attach.pattern.tmpl:91
Would change to
#: twikiplugins/PatternSkin/templates/attachtables.pattern.tmpl:25
Because only the references to the string locations would change, all translations would still work. But I propose that I update those references on 28 Dec.
This may sound like a feature request, but it
is important to have the underlaying template structure right.
AC
4.1.0 released
KJL