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 have a question you asked answered by someone - please remember to edit the page and set the status to answered. The status is in a drop-down list below the edit box.

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

-- GlennHart - 30 Apr 2008

 
Change status to:
Topic revision: r3 - 2008-05-01 - PeterThoeny
 
Twitter Delicious Facebook Digg Google Bookmarks E-mail LinkedIn Reddit StumbleUpon    
  • Download TWiki
TWiki logo Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2012 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.