[Date Prev][Date Next][Thread Prev][Thread Next][Interchange by date
][Interchange by thread
]
[ic] query built tabbed display... looking for "do once" tag
Hi guys,
I built a tabbed-display from a query. I initiate the tabs by generating
it with a [prefix-change] area, thus creating tabs for my 'vendor'
column. This works fine but in this, and other areas, but I always run
into this little ceveat that always negs me as being a inefficient hack.
In short, I was wondering if there was a way to have a block of code
only show once within an iteration, without using a continual
comparison.
Here is an example taken from the more complete usage below:
[stk-change 1][condition][stk-param vendor][/condition] # start
prefix-change
[if explicit] # see if it is the very first
iteration
[condition]
$num = '[stk-increment]';
return 1 if $num eq 1;
return 0;
[/condition]
[else]</table>[/tabbed-panel][/else][/if] # else close the table and
tabbed-panel
[tabbed-panel [stk-param vendor]] # and start a new panel
header
<table cellpadding=3 cellspacing=0 width=650 border=0>
<tr>
<td colspan=6> </td>
</tr>
<tr>
<td width=60> </td>
<td width=70><b>Date</b></td>
<td width=100><b>Title</b></td>
<td width=280><b>Description</b></td>
<td width=70 align=right><b>Count</b></td>
<td width=70 align=right><b>Adjusted</b></td>
</tr>
<tr>
<td colspan=6> </td>
</tr>
[/stk-change 1]
-------------------------------------------------------------------
I also do something like this with the [table-organize] tag elsewhere.
It seems when you want to take advantage of [prefix-change] it sees the
"first" group of values found as a "change" thus exposing the blocks
code, making it hard to "close" open tags. You kinda have to make an
"empty" initial tabbed area, or table (whatever the case).
I understand this works well for maybe creating an indented list, etc,
but what about for things like sorting things in table columns (or
tabbed pages) based on ORDER BY specs ?
In pseudo code I guess:
[prefix-do_once] Hello World [/prefix-do_once]
Any Ideas? Does this exist in some undocumented bowel of IC?
TIA
Paul
Code below is for completeness and should be snipped if one replies to
this thread.
--------------------------------------------------------
[query
ml=40
type=list
prefix=stk
list_prefix=stock
table=stock
sp="@@MV_PAGE@@"
sql=|
SELECT code, vendor, received, title, description, count
FROM stock
WHERE status != 1
ORDER BY vendor
|]
[tabbed-display
panel-width="660"
tab-width="100"]
[stock]
[stk-change 1][condition][stk-param vendor][/condition]
[if explicit]
[condition]
$num = '[stk-increment]';
return 1 if $num eq 1;
return 0;
[/condition]
[else]</table>[/tabbed-panel][/else][/if]
[tabbed-panel [stk-param vendor]]
<table cellpadding=3 cellspacing=0 width=650 border=0>
<tr>
<td colspan=6> </td>
</tr>
<tr>
<td width=60> </td>
<td width=70><b>Date</b></td>
<td width=100><b>Title</b></td>
<td width=280><b>Description</b></td>
<td width=70 align=right><b>Count</b></td>
<td width=70 align=right><b>Adjusted</b></td>
</tr>
<tr>
<td colspan=6> </td>
</tr>
[/stk-change 1]
[stk-alternate 2][tmp bg]bgcolor=#DFDFDF[/tmp][else][tmp
bg]bgcolor=#F9F9F9[/tmp][/else][/stk-alternate]
<tr [scratch bg]>
<td><b>received:</b></td>
<td>[convert_date fmt="%D"][stk-param received][/convert_date]</td>
<td><a href="[area href='cg/edit_stock' arg='[stk-param
code]']">[stk-param title]</a></td>
<td>[stk-param description]</td>
<td align=right>[stk-param count]</td>
<td align=right><a href="[area href='cg/add_job' arg='[stk-param
code]']">+ new job</a></td>
</tr>
[tmp num][stk-param count][/tmp]
[tmp needit][/tmp]
[query
ml=30
type=list
prefix=job
list_prefix=jobs
table=jobs
sp="@@MV_PAGE@@"
sql=|
SELECT code, job, date, amount
FROM jobs
WHERE stock_id = '[stk-code]'
AND status != 1
|]
[jobs]
<tr [scratch bg]>
<td align=right><a href="[area href='cg/edit_job' arg='[job-param
code]']"><b>sent:</b></a></td>
<td>[convert_date fmt="%D"][job-param date][/convert_date]</td>
<td colspan=2><b>job:</b> [job-param job]</td>
<td align=right><i>-[job-param amount]</i></td>
<td align=right> </td>
</tr>
[tmp newnum][/tmp]
[tmp newnum][calc][scratch num] - [job-param amount][/calc][/tmp]
[tmp num][scratch newnum][/tmp]
[tmp needit]1[/tmp]
[/jobs]
[/query]
[if scratch needit]
<tr [scratch bg]>
<td colspan=6 align=right>
<b> [scratch num] </b>
</td>
</tr>
[/if]
[/stock]
</table>
[/tabbed-panel]
[/tabbed-display]
[/query]