Gossamer Forum
Home : Products : Gossamer Forum : Development, Plugins and Globals :

Plugins - how toi print out content, and stop "1" showing at bottom of page?

Quote Reply
Plugins - how toi print out content, and stop "1" showing at bottom of page?
Hi,

I'm trying to write something that works with:

gforum.cgi?action=guestbook

Now, this works fine:

Code:
sub main {
# -----------------------------------------------------------------------------
# This subroutine will be called whenever the hook 'main' is run. You
# should call GT::Plugins->action(STOP) if you don't want the regular
# 'main' code to run, otherwise the code will continue as normal.
#
my (@args) = @_;

# Do something useful here
if ($IN->param('action') eq "guestbook") {

use GForum::Template;

my $do = $IN->param('do');
if (!$do) {
print $IN->header();
print GForum::Template->parse_print('error.html', { error => "FOO" } );
exit;
}
GT::Plugins->action(STOP);
}


return @args;
}

(the error.html bit is just to test the GForum::Template parsing bits :))

However, at the bottom of the page it shows:

Quote:
1

I've attached a screenshot.


I've also tried:

Code:
sub main {
# -----------------------------------------------------------------------------
# This subroutine will be called whenever the hook 'main' is run. You
# should call GT::Plugins->action(STOP) if you don't want the regular
# 'main' code to run, otherwise the code will continue as normal.
#
my (@args) = @_;

# Do something useful here
if ($IN->param('action') eq "guestbook") {

use GForum::Template;

my $do = $IN->param('do');
if (!$do) {
print $IN->header();
return GForum::Template->parse_print('error.html', { error => "FOO" } );
}
GT::Plugins->action(STOP);
}


return @args;
}

..but that prints out error.html, and then shows the normal pagePirate

Whats the correct way for printing out in GForum? I remember doing some stuff with PMManager back in 2004 - but all I can see in there, is stuff like:

return GForum::Template->parse_print('pmmanager_folder_page_sent.html', { pm_list => \@pms, %$vars } );

..and somehow, that seems to work right - so I'm not sure what I'm doing wrong :(

TIA for any suggestions .. in the mean time, I'll keep playing here =)

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates

Last edited by:

Andy: Feb 21, 2008, 4:47 AM
Quote Reply
Re: [Andy] Plugins - how toi print out content, and stop "1" showing at bottom of page? In reply to
Hi,

Anyone? GT?

This works fine: (Shows without a 1);

Code:
sub main {
# -----------------------------------------------------------------------------
# This subroutine will be called whenever the hook 'main' is run. You
# should call GT::Plugins->action(STOP) if you don't want the regular
# 'main' code to run, otherwise the code will continue as normal.
#
my (@args) = @_;

# Do something useful here
use GForum::Template;

my $do = $IN->param('func');
if ($do eq "view") {
view_guestbook();
} else {
print $IN->header();
return ('error.html', { error => "Invalid function called" } );
exit;
}

return @args;
}

.. yet if (for example) in view_guestbook(), I have this:

Code:
sub view_guestbook {

print $IN->header();
return ('error.html', { error => "Invalid function called" } );
exit;

}

..I get this error:

Quote:
Software error:

GT::Template::Parser (4871): Unable to locate template file 'Plugins::GForum::Guestbook' in '/var/home/linkssql/ultradev.com/cgi-bin/forum/admin/templates/default/../common' or any inheritance directories at GT::Template::_compile_template line 677.

For help, please send mail to the webmaster ([no address given]), giving this error message and the time and date of the error.

Can someone **PLEASE** shed some light on this - its really beginning to get on my nerves, as this plugin is almost ready to release - but cos of this silly "1" showing up, its still faulty Pirate

TIA

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Plugins - how toi print out content, and stop "1" showing at bottom of page? In reply to
As a programmer I'm surprised you don't know the reason for a "1" showing at the bottom of your page.

I would guess the reason for two pages displaying is that you have:

GT::Plugins->action(STOP);

....in the wrong place (i.e. AFTER you have already returned instead of before, so it never gets called).

As for the "1", it's probably because you are printing a print.....

print GForum::Template->parse_print('error.html', { error => "FOO" } );

Try:

GForum::Template->parse_print('error.html', { error => "FOO" } );

Last edited by:

Wychwood: Feb 22, 2008, 10:49 AM
Quote Reply
Re: [Wychwood] Plugins - how toi print out content, and stop "1" showing at bottom of page? In reply to
Hi,

Quote:
As a programmer I'm surprised you don't know the reason for a "1" showing at the bottom of your page.

Normally, it means it getting a "return" of TRUE (i.e the 1) .. but I didn't think that was the case in this.

Quote:
GT::Plugins->action(STOP);

....in the wrong place (i.e. AFTER you have already returned instead of before, so it never gets called).

Ya, that was a silly one =) Its not needed anyway, as the way this plugin uses "actions", so its not actually calling a plugin hook , which is why that function call would normally be use Smile

Quote:
As for the "1", it's probably because you are printing a print.....

print GForum::Template->parse_print('error.html', { error => "FOO" } );

Try:

GForum::Template->parse_print('error.html', { error => "FOO" } );

OMG - you're a star!!!! Works a charm. I can't believe it was so simple.

I tried so many different ways (print, return GT::Template, return 'template', {vars}, and more) - and all it needed was the print taken out.

Thanks again - thats really made my day Smile (not sure why GT couldn't have given some advise too :/)

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates