I'm struggling with something that is driving me so crazy
that I have to assume that the problem is incredibly obvious.

I'm using TT with Maypole, and trying to write a macro to 
generate a URL for a search. I'm using the "url" plugin to
handle the creation of the query string from a parameter
hash that comes from Apache.

I haven't been able to get the macro right, but while trying
to fix it, I seem to have hit a situation where the url
plugin is completely failing to work in an expected way,
but I have no idea what's going wrong.

My link-generation line is:

[% "<<<" _ search_link("page=${pager.next_page}", num) _ ">>>" %]

and the search_link macro, from a separate file, is:

[% MACRO search_link(addit_params, label) BLOCK %]
  [% USE url("$base${classmetadata.table}/search", search_params) %]
  [% '<a href="' _ url(addit_params) _ '">' _ label _ "</a>" %]
[% END %]

My intention is to create the base URL from some Maypole variables
and the "search_param" hash, and then add "addit_params", which
will be "page=2" or whatever, as generated by a separate pager.
the "num" is the page number, which will be hot-linked (it's the
"label" in the macro.

The link that this actually generates is something like

http://localhost/slangbiblio/slangbiblio/search/page=2?holding_lib=NYPL%25&title=the%25

with the "page=2" not preceded by the "?" for some reason; it's
this that I was trying to fix.

But while trying to debug it, I can't seem to make certain changes
at all, even though other changes have an effect. For example, if
I change the "USE url" line to this:

  [% USE url("www.mysite.com/search", search_params) %]

i.e. with a hard-coded URL, it has no effect--the URL still comes out
with the "localhost/slangbiblio" etc. in it. This is after starting
and restopping Apache for good measure. But it doesn't seem to be
a caching issue, because if I also change the next line to:

  [% '<a href="' _ url(addit_params) _ '">' _ "label" _ "</a>" %]

i.e. if I put the word "label" itself in quotes--then the link is
generated with "label" (the word itself) hotlinked, which says
to me that the macro is indeed being re-read--but still with
the "slangbiblio" stuff instead of the hard-coded URL.

I've tried a bunch of variants, including moving the macro definition
to the file in which it's being called, and changing the name to
something random like "nnk" in case it's being stepped on somewhere
else, and assigning the macro to a variable (i.e. "USE mysearchurl
= url(....")), and putting the hard-coded URL in single quotes,
but it keeps coming out the wrong way--both wrong with my
"slangbiblio" there regardless, and wrong with the "page=" in
the wrong place with the other query params, my original problem.

Can someone set me straight on what's happening here?

Thanks.

Jesse Sheidlower

_______________________________________________
templates mailing list
[EMAIL PROTECTED]
http://lists.template-toolkit.org/mailman/listinfo/templates

Reply via email to