[ic] Item-alternate leaves unnecessary white space
Dan Browning
interchange-users@icdevgroup.org
Wed Mar 26 01:51:01 2003
At 09:54 PM 3/25/2003 -0800, you wrote:
>Hi,
>
>Using IC4.8.5 on Redhat 7.2, default db, foundation.
>I'm having trouble finding a solution to this problem
>using the [item-alternate] tag. I use it on the
>results page to display 4 items per row, like this
>[item-alternate 4]:
>
>Category#1
>X X X X
>X X X X
>
>Category#2
>X X X X
>X X X X
>etc.
>
>However, I have several categories and less than 4
>items in some categories. This causes it to alternate
>leaving white space, for example, Category#2 starts
>out with item#4, so it alternates, as it should:
>
>Category#1
>X X X
>
>Category#2
>X
>X X X X
>X X
>etc.
>
>I need to alternate *only* if I am in the 4th column
>*unless* the category changes. How is this best
>overcome? I have been trying to implement some sort of
>counter using [calc] and [scratch] testing for column
>number 4, etc., but I just can't get it, and it seems
>too slow. I have looked into the looping tags but I
>don't quite understand them all. I've checked the mail
>archives but I am not sure what tag I should be using
>or what term to search on. Below is an example of my
>standard and 'counting column' code.
I think you are running into order of interpolation issues, and some of
your code was in disrepair. Try the (untested) changes I made
below. Also, you might try out [table-organize], I have found it very useful.
Best,
Dan
>Thanks to anyone who can offer any help!
>
>SKR
>_________________________________
>
>Here is my standard working code:
>
><table>
>[search-list]
>[item-change 1][condition][item-field
>category][/condition]
> <tr>
> <td colspan="4">[item-field category]</td>
> </tr>
> <tr valign="bottom">
>[/item-change 1]
>
><th><IMG SRC="thumb/[item-code]_b.jpg"></th>
>
>[item-alternate 4]</tr><tr valign="bottom"><td
>colspan="4"></td></tr>
><tr valign="bottom">[else][/else][/item-alternate]
>
>[/search-list]
></tr>
></table>
>
>Here is my attempt at counting columns. I think it
>would work if it ever compared to < 4 correctly:
>
><table>
>[search-list]
>[item-change 1][condition][item-field
>category][/condition]
> <tr>
> <td colspan="4">[item-field category]</td>
> </tr>
> <tr valign="bottom">
><!-- reset column counter on new category-->
>[seti col_count]0[/seti]
- [seti col_count]0[/seti]
+ [item-calc]$Scratch->{col_count} = 0; return;[/item-calc]
>[/item-change 1]
>
><!-- add 1 to the counter which indicates column # -->
>[seti col_count][calc][scratch col_count] +
>1[/calc][/seti]
Change this to [item-calc] as well.
><th><IMG SRC="thumb/[item-code]_b.jpg"></th>
>
><!-- if column # is equal to 4, terminate the row,
>else -->
>[if type=data term="[scratch col_count]" op="<"
>compare="4"][else]</tr><tr valign="bottom"><td
>colspan="4"></td>
> </tr>
> <tr valign="bottom">[seti
>col_count]0[/seti][/else][/if]
This would be
[item-calc]
if ( $Scratch->{col_count} < 4 ) {
# Do nothing?
} else {
$Scratch->{col_count} = 0;
# return html stuff
}
[/item-calc]
--
/~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\
| Dan Browning, Kavod Technologies, <dan.browning@kavod.com> |
| 6700 NE 162nd Ave, Suite 210, Vancouver, WA (360) 843-4074 x217 |
\~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~/
A large number of installed systems work by fiat. That is, they work
by being declared to work.
-- Anatol Holt