If a topic makes use of an
EDIT_TEMPLATE
preference, and this edit template hides the textarea using a
TMPL:INCLUDE{editform}
, a checkpoint-save will lose the edit tempate settings. It falls back to the default edit. The standard editform tempalte sets a hidden formfiled
editaction
to
form
, which is to be used on a checkpoint roundtrip. However, Edit.pm will happily read the EDIT_TEMPLATE settings and then append
form
to it for the next edit cycle. For example given
EDIT_TEMPLATE=FormEdit
it will try to read the template
FormEditform
after a checkpoint-save. As this does not exist, it will fall back to read the
edit
template.
That's an error in all TWiki-4.x versions.
Here's the responsible code from
Edit.pm
1 # Get edit template, standard or a different skin
2 my $template = $query->param( 'template' ) ||
3 $session->{prefs}->getPreferencesValue('EDIT_TEMPLATE') ||
4 $templateName;
5
6 $tmpl =
7 $session->templates->readTemplate( $template.$editaction, $skin );
8
9 if( !$tmpl && $template ne $templateName ) {
10 $tmpl = $session->templates->readTemplate( $templateName, $skin );
11 }
12
13 if( !$tmpl ) {
14 throw TWiki::OopsException(
Ok, so what happens here? First, the name of the template to be used for editting is read in lines 2-4. This will find the
EDIT_TEMPLATE
settings in the topic. However in line 6-7 it will append the
$editaction
. This is the empty string the first time the topic is editted, and
form
during the checkpoint-save. So the first time the correct edit template is found in lines 6-7. Not so the second time. The second time, it will fall back to read the 'edit' template ($templateName = 'edit' in general). At this point nor the template specified via urlparam, nor the EDIT_TEMAPLTE settings will be used anymore.
So what exactly is line 9 telling me? Why is there a
$template ne $templateName
check? I'd remove it and replace lines 9+10 with
if( !$tmpl ) {
$tmpl = $session->templates->readTemplate( $template, $skin );
}
--
TWiki:Main/MichaelDaum
- 31 Oct 2007
Changed to BeingWorkedOn pending Micha's checkin
CC
Done
MD