Tags:
create new tag
view all tags

Question

As mentioned in BulletListNotRenderedOnOutputOfPlugin, I have a plugin that extracts form data and displays it. I now came across a bug in my plugin when rendering a preview page: Within the plugin, I use TWiki::Func::readTopic() to extract the meta data and read form fields from that. The problem is that when rendering the preview page, my plugin still uses the data stored on disk to render the field's value instead of the data entered on the edit page.

Is there a way to get the topic's data (text and meta) from within a plugin when previewing a topic?

Environment

TWiki version: TWikiRelease01Feb2003
TWiki plugins: TopicVarsPlugin, KnowledgeBasePlugin, ConditionalPlugin, DefaultPlugin, InterwikiPlugin
Server OS: Debian GNU/Linux 3.0 (woody), kernel 2.3.19-ac4
Web server: Apache 1.3.26
Perl version: 5.6.1
Client OS: Windows 2000, SP4
Web Browser: Mozilla 1.4

-- ThomasJachmann - 02 Oct 2003

Answer

I hacked a solution myself now, unfortunately having to change TWiki core code:

  • preview script
    $text = $meta->write( $text );  # add meta data for Plugin callback
    TWiki::Plugins::afterEditHandler( $text, $topic, $webName );
    $meta = TWiki::Meta->remove();  # remove all meta data
    $text = $meta->read( $text );   # restore meta data
         
    instead of just
    TWiki::Plugins::afterEditHandler( $text, $topic, $webName );
         
    This code is taken from TWiki::Store::saveTopic

  • TWiki::Plugins::KnowledgeBasePlugin::afterEditHandler
    This method now takes the meta data from the $text variable and extracts the meta data which will be used in subsequent calls to the plugin during preview

BTW: Is there a reason why meta data is contained within $text for say beforeSaveHandler but not for afterEditHandler?

Maybe someone can approve/disapprove my approach.

-- ThomasJachmann - 10 Oct 2003

What you describe seems very convoluted. TWiki::Form::fieldVars2Meta( $webName, $query, $meta ) is available to convert query parameters to $meta; you should probably use this instead of touching the core code.

The various handler APIs are not well specced; the asymmetry in the calls is probably just due to the way the handler calls were added and the needs at the time of the person who added them. I suspect there is no "plan" behind the difference.

-- CrawfordCurrie - 02 Jun 2004

Edit | Attach | Watch | Print version | History: r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r3 - 2004-06-02 - CrawfordCurrie
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.