mi-espacio.com - Thomas wrote:
Hi List, this is Thomas
I'm quite new at TT, and i hope anyone can give me a hand on my subject.
Given problem exists if a user does not accept cookies, i have to send
the session by the A -TAG, but i didn't find any hint how to edit the
tt->process that it is able to add a value to any href starting with
"http.." or "/..."
Is there any way to do so?
[SNIP]
Here are two ways you could do this. (I'm sure other people have other
methods.) Use a routine to create your links for you or post process the TT
content.
Method 1.) Stop hard coding links and create some kind of routine that builds your
links for you. We utilize a method like so: [% api.url('index.html') %]. This
automatically prepends the server portion as well as appends session ids if
necessary. It also automatically does uri encoding and html encoding. (Toggle-able
via options passed.) You pass your routine in with the vars parameter to
->process. An example vars:
{
api => {
url => sub{
my ($page, $cgi_hash_or_string, $opt) = @_;
#build link here.
}
}
}
You don't have to use the api key there, however, I like to keep clutter of TT
top level variables down.
Links now look like:
<a href="[% api.url('index.html') %]">index page</a>
Method 2.) Post process your content. Use an HTML parser and modify all links
as necessary.
I like the first method, because it gives you a lot of control over the links
on your site.
-- Josh
_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates