[Zope-DB] Creating a hyperlink using results from query

Cliff Ford Cliff.Ford at ed.ac.uk
Fri Apr 8 06:17:57 EDT 2005


Martin Jennings wrote:
> Firstly, thank you to those who answered by query on the empty result set,
> it set me on the way to finding a solution.
> 
> Not sure if this is the right list to ask on, but here is the question.
> 
> I have got information from a ZSQL request in a result set and I want to
> use one of the values as a parameter in a hyperlink, how do I do this?
> 
> I.e. <a href="htmlPage?parameter=ZSQLValue">my link<a>
> 
> How do I write the code for this?

It depends on how you are calling the ZSQL Method, and whether you are 
returning one result or many. In DTML it could be like this:

<dtml-in nameOfZSQLMethod>
<a href="htmlPage?parameter=<dtml-var FieldName>"><dtml-var 
FieldNameOfLinkText><a><br>
</dtml-in>

You can shorten <dtml-var FieldName> to &dtml-FieldName; - but I thin 
you should get the idea.

Python uses
for result in context.nameOfZSQLMethod():
     return '<a href="htmlpage?parameter=%s">Link Text</a>' % \
         result.FieldName

HTH

Cliff

> 
> Thank you in advance, and once again, sorry if this is not the correct list.
> 
> Martin Jennings
> 
> _______________________________________________
> Zope-DB mailing list
> Zope-DB at zope.org
> http://mail.zope.org/mailman/listinfo/zope-db


More information about the Zope-DB mailing list