* Parker, Brian <[EMAIL PROTECTED]> [2002-07-22 17:33]:
> OK, here is what I've got (in case anyone is interested):
>
> [% Use myurl = url('/cgi-bin/blah.pl') %]
> [% Use Sticky %]
> <a href="[% myurl(action="blah1") |
> sticky('param1','param2') %]">Do Blah</a>
>
> The above makes generates the following (assuming that param1
> and param2 are defined when the page is rendered):
> <a href="/cgi-bin/blah.pl?action=blah1¶m1=value1¶m2=value2">Do Blah</a>
This is interesting. My initial idea for an approach was more along the
lines of modifying Template::Plugin::URL to take, as an argument,
something that has a param method, so that you could do:
[% USE q = cgi %]
[% USE myurl = url("/my/url", q) %]
And then, when you call myurl, it would iterate over not only the
parameters passed in, but also the parameters that are returned by
$q->param. This has the disadvantage of propagating *every* parameter
that q has, though, while yours only maintains specific ones.
Note that I was envisioning the plugin taking something that
can("param"), so that you could use something like Apache::Request under
mod_perl.
Attached is a patch that will allow you to set the parameter separator,
using something like:
$Template::Plugin::URL::PARAM_SEPARATOR = ";";
before you process your templates.
(darren)
--
You can put a man through school, but you cannot make him think.
-- Ben Harper
--- URL.pm.orig Tue Jul 23 10:17:59 2002
+++ URL.pm Tue Jul 23 10:22:52 2002
@@ -27,12 +27,12 @@
require 5.004;
use strict;
-use vars qw( @ISA $VERSION );
+use vars qw( @ISA $VERSION $PARAM_SEPARATOR );
use Template::Plugin;
@ISA = qw( Template::Plugin );
$VERSION = sprintf("%d.%02d", q$Revision: 2.52 $ =~ /(\d+)\.(\d+)/);
-
+$PARAM_SEPARATOR = '&' unless defined $PARAM_SEPARATOR;
#------------------------------------------------------------------------
# new($context, $baseurl, \%url_params)
@@ -49,7 +49,7 @@
my $newbase = shift unless ref $_[0] eq 'HASH';
my $newargs = shift || { };
my $combo = { %$args, %$newargs };
- my $urlargs = join('&',
+ my $urlargs = join($PARAM_SEPARATOR,
# map { "$_=" . escape($combo->{ $_ }) }
map { args($_, $combo->{ $_ }) }
grep { defined $combo->{ $_ } }