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,