Hi there,
Attempting to run a loop inside another (nested loops), I’ve written 2 template::multirow together with 2 foreach loops. The goal is to fill in an input type text as a series of form elements. (I’m not using ad_form / acs-templating)
I’ve read the documentation about —local and -ulevel, but there isn’t many examples, except for diagram package, which is very hard to visualize and understand its implementation.
https://openacs.org/forums/message-view?message_id=52050
https://openacs.org/api-doc/proc-view?proc=template::multirow&source_p=1
https://openacs.org/forums/message-view?message_id=103734
I noticed diagram pkg has a something similar, but I couldn’t run the package and evaluate it source code.
The chunk of code follows the example below:
multiple name="rooms"
div class="box-capacities-detail"
form
div class="left-capacities"
input type="hidden" id=“room_id" name=“room_id" value=“@rooms.id@"
input type="text" id=“name" name=“name" style="width:80%; float:right;" size="50" value="@rooms.name@" placeholder="Nome do Espaço"
/div
if @categories_p@
multiple name="categories”
div class="col-5-capacities"
mailto:h3@categories.name@/h3
input type="text" id="mailto:cat_@categories.id@" name="mailto:cat_@categories.id@" value=“@categories.value@"
/div
/multiple
/div
/if
…
The problem’s in second multiple block (i.e. “categories”) to represent a two level data structure, using template::multirow . Perhaps, I shouldn’t even use it at all.
I’ve tried too the following line, but as expected it didn’t workout well.
<input type="text" id="mailto:cat_@rooms.categories.id@" name="mailto:cat_@rooms.categories.id@" value=“@rooms.categories.value@">
Such representation would never work! :) rsrsrs
multiple rooms
@elem.id@
@elem.name@
…
multiple categories
@elem.cats.id@
@elem.cats.name@
@elem.cats.value@
…
/multiple
…
/multiple
Then, simplifying and linearizing the implementation I tried the following line, but it displays only the very last element of the list.
<input type="text" id="mailto:cat_@categories.id@" name="mailto:cat_@categories.id@" value=“@categories.value@">
As a turn around I’ve tried reset the multirow, right in the end of the external foreach statement loop, but it unsets the entire multirow structure.
I’ve tried a third approach writing a unique multirow with all values in one single reach statement, but it did’t work either
elems
elem1_id elem1_name elem1_cat1_id elem1_cat1_name elem1_cat1_value
elem1_id elem1_name elem1_cat2_id elem1_cat2_name elem1_cat2_value
…
elem1_id elem1_name elem1_catM_id elem1_catM_name elem1_catM_value
…
elemN_id elemN_name elemN_cat1_id elemN_cat1_name elemN_cat1_value
…
elemN_id elemN_name elemN_catM_id elemN_catM_name elemN_catM_value
I’m pretty sure I’ve done this in the past, but I’ve lost my backups and now I’m stuck trying to figure out a way to implement a data structure as sort of:
How would I implement and represent a two-level multirow in ADP file? Is it even possible?
Best wishes,
Iuri