[Zope-DB] dynamic order by clause in sql query
Thu, 7 Feb 2002 13:58:43 -0800
I have a sql method that I have define as follows :
select field1, field2, field3 from mytab order by field1.
I have a dtml-doc to display the results. The results display in a typical
html table. I would like to have the table headers be links to re-sort the
same page by whatever field the user chooses. Currrently, I have 3 sql
methods (to sort explicitly on field1 or field2 or field3) and 3 separate
dtml doc to display the results.
I would like to cut this down to 1 sql method for the sql and 1 dtml doc for
I have defined a new sql method (sql_1) as follows (the arg is
select field1, field2, field3 from mytab order by <dtml-sqlvar order_by_col
I can test this out fine. If I pass a 1,2, or 3 my results will be sorted
by the appropriate column.
I can't get the dtml doc (doc1) to work with my new sql method. How can I
create the links to call the same page that I'm on. I have the following
<th><a href="mypath/sql1/1/doc1">field1</a></th> (note: I want click
and sort on col 1)
I haven't had success getting this to work.
Is there a better way to do this?