Forum OpenACS Q&A: passing datastructures to adp's

Collapse
Posted by tammy m on
Hi

I want to pass what is effectively an array of lists or I would settle for an array of arrays (a multi-dimensional array) to an adp page from a tcl datasource (page). Is there a "right way" to do this? I am finding  myself coming up with all sorts of hacks:( I'm sure someone out there has done this before!

Basically I need to pass an indefinite/changing number of items for each record (and I also I don't know how many records I could have)...

As an example, I have a list of recommended restaurants and then for each restaurant, I have the name, a review and then I can have any number (0 - N) of comments on their service. How would I pass all of this information to an adp in an easy to access datastructure for formatting?

Collapse
Posted by Claudio Pasolini on
You should use db_multirow to query your restaurant table. The API builds a multirow data structure (let's say restaurant:multirow) that you can pass to the adp page via the property section of ad_page_contract. In the adp page you can use the <multiple> tag with the notation @reastaurant.name@ to display each item.
Collapse
Posted by Tom Jackson on

But I think the -property block of ad_page_contract doesn't do too much enforcing. If you use a db_multirow and leave that out of the -property block, the page will still work.

Also, you are not passing any data to the adp file. In the templating system, the file with the adp ending is actually a template that is compiled into tcl code and executed after the tcl file is sourced. I believe the term used in the templating system documentation is 'preparing datasources'. This is what happens in the tcl file.