Gossamer Forum
Home : Products : DBMan SQL : Discussion :

Simple question about variables & GT-module

Quote Reply
Simple question about variables & GT-module
I need to make the subroutine in Template Globals:
1) To read through already existing variable.
2) To make some with it on a pearl (It I can) Wink
3) Both to create a new variable and to appropriate to it turned out value.

Help with 1 and 3 item: it is necessary to read through <%VarData%> and to create <%VarData2%>

As you have understood - English at me not the native language... 8))))

Last edited by:

Printsite: Sep 27, 2004, 2:00 PM
Quote Reply
Re: [Printsite] Simple question about variables & GT-module In reply to
Hi,
I'm not exactly sure what you want to do but here is a basic example for you to start with -

Create a Template Global called -
test
(or any name you like) and include the following code -


sub {
#make existing variables available
my $tags = GT::Template->tags;

#do something here
#existing variables will be available using -
$tags->{variable_1_name};
$tags->{variable_2_name};
#etc, etc........

#assign new variables to be available in your template
$tags->{new_variable_1}="something";
$tags->{new_variable_2}="something else";
#etc, etc........


#if you want to return something to your template
my $output="Return something to your template";
#note new variables will be returned and don't need to be included here

#return the result to your template
return $output;
#or if you have nothing to return you can just use -
# return;

#end sub
}



You can call the sub from your template using -
<%test%>
(or whatever name you used for the sub)

Hope that helps.
Simon.
Quote Reply
Re: [jai] Simple question about variables & GT-module In reply to
Thanks, you helped me.

Code:

sub {
my $tags = GT::Template->tags;
$tags->{textv_p} = $tags->{textv};
$tags->{textv_p}=~ s/\r?\n/<br>/g;
return;
}
Quote Reply
The post can be deleted! In reply to
Subj!