Gossamer Forum
Quote Reply
simple plugin
Hello,
I'm trying to understand how plugins work and I have been doing very simple plugin, but I'm totaly lost.

I want to add tag "display" to link.html page which will print URL of link (synonym for <%URL%>). But currently tag <%display%> generate
"Unknown Tag: 'display'".

Can you give me advice what I'm doing wrong? And yes, I was googling and searching this forum all this afternoon.

Miroslav Suchy

My Install.pm:
Code:
package Plugins::Test;
# ==================================================================
use strict;
use vars qw/$VERSION $DEBUG $NAME $META/;
use GT::Base;
use GT::Plugins qw/STOP CONTINUE/;
use Links qw/:objects/;

$VERSION = '1.0';
$DEBUG = 0;
$NAME = 'Test';
# Inhert from base class for debug and error methods
@Plugins::Test::ISA = qw(GT::Base);

$META = {
'author' => 'Miroslav Suchy',
'description' => '',
'license' => 'GPL',
'prog_ver' => '2.1.2',
'url' => '',
'version' => '1.0'
};


sub pre_install {
# -----------------------------------------------------------------------------
# This function displays an HTML formatted message that will display any
# instructions/information to the user before they install the plugin.
#
my $inst_msg = '';

return $inst_msg;
}

sub pre_uninstall {
# -----------------------------------------------------------------------------
# This function displays an HTML formatted message that will display any
# instructions/information to the user before they remove the plugin.
#
my $uninst_msg = '';

return $uninst_msg;
}

sub install {
# -----------------------------------------------------------------------------
# This function does the actual installation. Its first argument is a plugin
# manager which you can use to register hooks, install files, add menu options,
# etc. The second argument is a GT::Tar object which you can use to access any
# files in your plugin module.
#
# You should return an HTML formatted string that will be displayed to the
# user.
#
# If there is an error, return undef, and set the error message in
# $Plugins::Test::error
#
my ($mgr, $tar) = @_;

$mgr->install_hooks('Test', [['site_html_link', 'PRE', 'Plugins::Test::display', '']]);

return "The plugin has been successfully installed!";
}

sub uninstall {
# -----------------------------------------------------------------------------
# This function removes the plugin. Its first argument is also a plugin
# manager which you can use to register hooks, install files, add menu options,
# etc. You should return an HTML formatted string that will be displayed to the
# user.
#
# If there is an error, return undef, and set the error message in
# $Plugins::Thumbnail::error
#
my $mgr = shift;

$mgr->uninstall_hooks('Test', [['site_html_link', 'PRE', 'Plugins::Test::display', '']]);
;
return "The plugin has been successfully removed!";
}

1;

And Test.pm:
Code:
package Plugins::Test;
# ==================================================================

use strict;
use GT::Base;
use GT::Plugins qw/STOP CONTINUE/;
use Links qw/:objects/;

# Inherit from base class for debug and error methods
@Plugins::Test::ISA = qw(GT::Base);

# PLUGIN HOOKS
# ===================================================================


sub display {
# -----------------------------------------------------------------------------
# This subroutine will be called whenever the hook 'site_html_link' is run. You
# should call $PLG->action(STOP) if you don't want the regular
# 'site_html_link' code to run, otherwise the code will continue as normal.
#
my $args = shift;

return {'display' => $args->{'URL'} };
}

# Always end with a 1.
1;
Subject Author Views Date
Thread simple plugin mirek 3119 Sep 12, 2005, 9:14 AM
Thread Re: [mirek] simple plugin
brewt 3035 Sep 12, 2005, 12:27 PM
Thread Re: [brewt] simple plugin
mirek 3027 Sep 12, 2005, 2:23 PM
Thread Re: [mirek] simple plugin
brewt 3024 Sep 12, 2005, 4:02 PM
Post Re: [brewt] simple plugin
ryel01 2986 Sep 13, 2005, 6:37 PM