Home : Products : Gossamer Links : Discussions :

Products: Gossamer Links: Discussions: Re: [brewt] How can I add a variables like $User/user $CFG/config which are available everywhere: Edit Log

Here is the list of edits for this post
Re: [brewt] How can I add a variables like $User/user $CFG/config which are available everywhere
Hi Adrian,

Thank you very much for your reply and hint.
I tried to define some variables in %STASH within a Plugin hooking to init.
I cannot see how to make them available in scripts and templates.
I tried a Plugin hook:

Code:
sub init {
my (@args) = @_;

$STASH{test} = "I was here!";
return @args;
}

... and it did not work. I thought a problem might be this part of sub init { within Links.pm

Code:
$PLG->dispatch('init', sub {});

(%STASH, $GLOBALS, $LANGUAGE, $USER) = ();
}
I changed it to:
Code:
$PLG->dispatch('init', sub {});

(%STASH, $GLOBALS, $LANGUAGE, $USER) = ();
$STASH{anothertest} = "...and here";
}

The code did not make anything show up neither in a perl script nor in a template (I used Data Dumper for %STASH which is empty, $STASH{test), $STASH{anothertest} and <%STASH.test%>).

It would be great to get another hint.

I thought of using $IN as well but I do not like this one either but maybe there is no problem:
Code:
sub init {
my (@args) = @_;
$IN->{mystash} = {};
$IN->{mystash}->{test} = "... and here as well";
return @args;
}
I guess the code is just dynamically and cannot be overwritten by params. So it might be better than using $CFG but %STASH seems to be more reasonable.

Regards

n||i||k||o

Last edited by:

el noe: Jun 8, 2011, 3:27 AM

Edit Log: