Forum OpenACS Development: Re: Two levels multirow

Collapse
4: Re: Two levels multirow (response to 3)
Posted by Iuri Sampaio on
One more thing to mention,

The example your provided is quite different. I believe group tag is not necessary in this case. The key is to learn how do I reset the second (inner) multirow, without unset the whole datasource.

In a simple TCL variable it'd be something as in the example I've written bellow with +++

...
foreach id [pa_all_photos_in_album $album_id] {
set info_list [photo_album::photo::get -photo_id $photo_id]

...
multirow append photos $info_list
...

+++ set info_list ""
}

Best wishes,

Collapse
5: Re: Two levels multirow (response to 4)
Posted by Iuri Sampaio on
Brian and community,

I found a solution to the problem. I've added photo_id obtained in the first (outter) multirow, to the second (inner) multirow.

That why I'm able to validate and display the elements of the "inner" multirow depedding on the id matching conditional.

#TCL
...
template::multirow create photos id name thumb

template::multirow create categories_mapped photo_id category_id name value
...

#ADP
...
if categories_mapped.photo_id eq photos.id
...

See the entire example at pastebin.com:
pastebin.com/JxG4Wmhs

The question now is: is there a better approach?

Best wishes,

Collapse
6: Re: Two levels multirow (response to 5)
Posted by Gustaf Neumann on
wouldn't it be easier to extend the "photos" multirow from Tcl by an extra attribute for the categories, which is used in the adp for rendering the matching categories information?
Collapse
7: Re: Two levels multirow (response to 6)
Posted by Iuri Sampaio on
Yes, if I didn't have to add category names, ids and values dynamically, in several input text fields, such as the one below. Because of it, two nested loops are required still. Perhaps, I don't visualize your approach in order to implement it.

I'm going to play a bit more using your tip and burn more neurons out! :)

...
input type="text" id="mailto:cat_@categories_mapped.category_id@" name="mailto:cat_@categories_mapped.category_id@" value="@categories_mapped.value@"
...

Gustaf,
I've tried that one too, as in the sample bellow. categories element as a list of lists with 3 elements each. But then, looping over those elements in the same main & unique loop (foreach statement) would be tough.

template::multirow create photos id name thumb categories

...

foreach category_id [category_tree::get_categories -tree_id $tree_id] {
set value [db_string select_value {
SELECT value
FROM ee_photo_category_map
WHERE category_id = :category_id AND photo_id = :photo_id
} -default ""]
...

multirow append photos $photo_id $photo(caption) $photo(thumb_image_id) {$photo_id $category_id $name $value}

My code just doesn't seem simple and clean. But that's just about a "feeling"

Best wishes,

Collapse
8: Re: Two levels multirow (response to 7)
Posted by Iuri Sampaio on
"mailto" in the string above was a TYPO included automatically by OACS Forum source code

...
input type="text" id="mailto:cat_@categories_mapped.category_id@" name="mailto:cat_@categories_mapped.category_id@" value="@categories_mapped.value@"
...