Gossamer Forum
Home : Products : Gossamer Links : Discussions :

hooks for 'display'

Quote Reply
hooks for 'display'
Alex,

I'm going to take a break for a few hours.

Could you explain how the hooks for SiteHTML::Display work?

I'm not having success passing/picking up the values for add_success

When I look at the value passed into the plug-in when I:

my $link = shift;

$link is empty. It really should have the $vars value from:

GT::Plugins->dispatch ($CFG->{admin_root_path}, "site_html_$template", $code, $vars);

Which should be the $results value from the add.cgi

or am I missing something???

I'm going to be off line for most of the night now. Kids are having a birthday party, and I figure I won't be able to get back on line til at least 9pm my time 6pm yours... (or I risk marital repercussions <G>)

So if I miss you, have a great weekend... and keep working ! <G>

Unfortunately, until you stop fiddling with things, we developers are going to be working blind as to whether it's our bug or yours!




PUGDOGŪ
PUGDOGŪ Enterprises, Inc.
FAQ: http://pugdog.com/FAQ


Quote Reply
Re: hooks for 'display' In reply to
Hi Pugdog,

I think this one is your bug. =) site_html_ hooks work as follows:

PRE hooks:

They get passed in a single hash reference of all the template tags that would appear on that template. So for site_html_add_success template you would get a hash ref of the entire link that was just added. The plugin can alter that hash ref to add tags, or change values. So if your plugin wanted to add the word 'foo' to the Title when displaying a link that was just added, you would do:

sub add_foo {
my $link = shift;
$link->{Title} = $link->{Title} . 'foo';
return $link;
}

and register add_foo as a PRE hook for add_success. I just tested this locally and works as expected.

POST hooks take as input a single scalar of the fully formmated template. You can modify that template and return it. So to remove all occurrences of the word foo in the template you would do:

sub remove_foo {
my $template = shift;
$template =~ s/foo//g;
return $template;
}

and register that as a POST handler.

I've tried both of these and they work fine. Let me see how you've done it and I'll see what's up.

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: hooks for 'display' In reply to
I found it...

See my post on 'die' in the plug in code.

I had what should have been a fatal error condition that was apparantly being trapped.

PUGDOGŪ
PUGDOGŪ Enterprises, Inc.
FAQ: http://pugdog.com/FAQ


Quote Reply
Re: hooks for 'display' In reply to
Also,

Is there a way to hook into "display" itself?

For instance, adding new global tags, or features that should be accessible on all template printing, would run into problems if each site_html_template routine had to be named by name.

For instance... I need to add a couple of "paths" to locations of stored data, that should be available in all templates. The fields/tags in the database refer to user-manipulable locations that need to be set.



PUGDOGŪ
PUGDOGŪ Enterprises, Inc.
FAQ: http://pugdog.com/FAQ


Quote Reply
Re: hooks for 'display' In reply to
Hi,

No, you would need to add a new global tag yourself to do this. Something like:

my $globals = do "$CFG->{admin_root_path}/templates/default/globals.txt";
if ($@) {
# error, couldn't load globals.txt file.
}
$globals->{new_option} = 'new value';
require GT::Dumper;
open (GLOBALS, "> $CFG->{admin_root_path}/templates/default/globals.txt") or ...
print GLOBALS GT::Dumper->dump ( var => 'my $dump', data => $globals);
close GLOBALS;

Hope that helps,

Alex

--
Gossamer Threads Inc.