[ic] possible bug in [item-alternate] ic5.2
Mike Heins
mike at perusion.com
Tue Nov 9 12:11:52 EST 2004
Quoting Olaf Kolling (kolling at w3welt.de):
> Hello,
>
> i think i found a bug in the [item-alternate]-tag of ic 5.2
> It would be great if someone could confirm and maybe even fix this...
i think you are right in the first_only, which should show up on every
page.
[snip]
> The problem is the inconsistent behavior of
> [item-alternate first_only] and [item-alternate last_only].
>
> As you can see the [item-alternate first_only]-part is output only on
> the very first result (as it's name suggests) but the [item-alternate
> last_only] shows up with the last result on each page (which is wrong
> but the behavior i need ;-)
>
> So someone should fix the behavior of the current tags to be
> consistent with the naming and docs and additionally write two
> new tags:
>
> first_only --> just on the first result of all (ok right now)
> last_only --> only on the last result of all (fix neccessary)
>
> And then two new tag (just a naming-suggestion ;-):
> firstgroup_only --> on the first hit on each results-page (new todo)
> lastgroup_only --> on the last hit of each results-page (behaviour of the current last_only)
>
i did it different -- i made first_only and last_only operate as
they were intended, on the page. i added absolute_first and absolute_last,
which are for only the first and last in the entire results array.
try this patch:
Index: Interpolate.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Interpolate.pm,v
retrieving revision 2.226
diff -r2.226 Interpolate.pm
3877c3877
< my ($count, $inc, $end) = @_;
---
> my ($count, $inc, $end, $page_start, $array_last) = @_;
3890c3890
< $status = 1 if $count == 1;
---
> $status = 1 if $count == 1 || $count == ($page_start + 1);
3893c3893
< $status = 1 unless $count == 1;
---
> $status = 1 unless $count == 1 || $count == ($page_start + 1);
3895c3895
< elsif('last_only') {
---
> elsif($inc eq 'last_only') {
3897a3898,3903
> elsif($inc eq 'absolute_last') {
> $status = 1 if $count == $array_last;
> }
> elsif($inc eq 'absolute_first') {
> $status = 1 if $count == 1;
> }
3903a3910,3911
> my $page_start = $i;
> my $array_last = scalar @{$ary || []};
4008c4016
< alternate($count, $1, $end)
---
> alternate($count, $1, $end, $page_start, $array_last)
it may not be exact, as it is against cvs.
--
Mike Heins
Perusion -- Expert Interchange Consulting http://www.perusion.com/
phone +1.765.647.1295 tollfree 800-949-1889 <mike at perusion.com>
p.s. sorry for lower case, injured hand
Software axiom: Lack of speed kills.
More information about the interchange-users
mailing list