Gossamer Forum
Home : Products : Gossamer Forum : Discussion :

Need a global for <%search_string%>

Quote Reply
Need a global for <%search_string%>
Hi,

I need to create a global which allows to change "+" for "%20" between keywords when <%search_string%> variable is printed.

Thank you for your help!!

François Smile
Quote Reply
Re: [Franco] Need a global for <%search_string%> In reply to
Code:
sub {
my ($tag, $str) = shift;
$str =~ s/+/%20/g;
return { $tag => $str };
}
That should do it. To call it, just put: <%globalvar(search_string => $search_string)%>; after calling it, search_string will have +'s replaced with %20's.

Jason Rhinelander
Gossamer Threads
jason@gossamer-threads.com
Quote Reply
Re: [Jagerman] Need a global for <%search_string%> In reply to
Thank you very much Jason for your answer!

When I add this new global var I get this error in all my forum:

A fatal error has occurred: panic: pp_iter at /home/.../public_html/admin/GForum/Template.pm line 72.

I even didn't add the global in my templates... The fatal error appears just by creating this global.

Thank you for your help!

François
Quote Reply
Re: [Franco] Need a global for <%search_string%> In reply to
HMm I think:

my ($tag, $str) = shift;

..needs to be

my ($tag, $str) = @_;

...and:

$str =~ s/+/%20/g;

should be:

$str =~ s/\+/%20/g;
Quote Reply
Re: [Paul] Need a global for <%search_string%> In reply to
Thank you very much Paul!

With your changes, there is now no fatal error, but the tag <%globalvar(search_string => $search_string)%> gives no results (nothing prints). Frown

Thank you!

François
Quote Reply
Re: [Franco] Need a global for <%search_string%> In reply to
Hi François,

The tag doesn't actually print anything - it just changes a variable. After you call the global, you need to put <%search_string%> again - after the call, it will have changed the +'s to %20's.

Jason Rhinelander
Gossamer Threads
jason@gossamer-threads.com