Tags:
create new tag
view all tags

Question

I am trying a different way to read my META data now. I am trying to write a plugin, but nothing is happening. In my topic I write:

%METADATA{type="PREFERENCE" name="LINK" key="value"}%
In my topic I have:

%META:PREFERENCE{name="LINK" title="LINK" value="TestTopic"}%

My plugin has the code:

sub commonTagsHandler {

    return unless $_[0] =~ m/%METADATA%/g;
        
     $_[0] =~ s/%METADATA%/_handleTag($_[0], $_[1], $_[2], $_[4])/ge;
}

# =========================
sub _handleTag {
    my( $theText, $theTopic, $theWeb, $theMeta ) = @_;

    if($theText =~ m/%METADATA{(.*)}%\n/g){
         my %params = TWiki::Func::extractParameters($1);
       my $att = $theMeta->get($params{type}, $params{name});
       my $key = $params{key} || 'name';
   
       return $att->{$key};
    }
 
    return '';
}

I am not an expert at PERL. I just copied and modified from other plugins.

Environment

TWiki version: TWikiRelease04x02x00
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin
Server OS: WindowsXP
Web server: Apache2.2
Perl version:  
Client OS: WindowsXP
Web Browser: Explorer, Firefox
Categories: Plugins

-- GlennHart - 29 Apr 2008

Answer

ALERT! If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.

I figured it out. My search for the variable was incorrect.

-- GlennHart - 30 Apr 2008

Change status to:
Edit | Attach | Watch | Print version | History: r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r3 - 2008-05-01 - PeterThoeny
 
  • 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.