Akopia Akopia Services

[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date ][Minivend by thread ]

Re: [mv] More list into two variables? Next & Previous



******    message to minivend-users from "Bill Randle" <billr@exgate.tek.com>     ******


On Oct 4,  4:36pm, minivend@hq.com.au wrote:
} Subject: [mv] More list into two variables? Next & Previous
} ******    message to minivend-users from minivend@hq.com.au     ******
}
} Looking through the docs;
} [more-list next_img prev_img none 0]
} [more]
} [/more-list]
} Makes 2 Images on the results page for next and previous.
}
}
} How can I make them 2 variables to recall without hacking Interpolate.pm?
}
} So I have a Next and Previous Variable that is updated with each search....
}
} Ideas?
}
} Geoff

Geoff,

When I first saw your question, I figured there must be some
hook to pick up the URLs for previous and next. However, when
nobody responded and you reposted your question, I took it as
a challenge to see if it could be done.

After looking at tag_more_list() in Interpolate.pm (MV4.04) for awhile,
it became obvious that there was no built in facility to get the
previous and next links because tag_more_list() inserts the links
directly into the page and doesn't set any handy vars with the info.

The easiest way, would be to hack Interpolate.pm and stick a copy
of the link text into a couple of scratch vars. However, since you
specifically said you didn't want to do that, the alternative is
to extract the the code in tag_more_list() and put in your own
[perl] block, UserTag, GlobalSub. etc.

I tested the [perl] block below with MV4.04 and it looks like it works.

BTW, Mike: I notice a minor typo on line 2793 of Interpolate.pm:

<	if($r =~ s:\[prev[-_]anchor\]($All)\[/prev-anchor\]::i) {
---
>	if($r =~ s:\[prev[-_]anchor\]($All)\[/prev[-_]anchor\]::i) {


	-Bill

[perl global=1]
    # This perl script extracts info from the current SearchObject
    # to build our own previous and next links just like
    # [more-list] does. In fact, this code coem directly from
    # tag_more_list() in Interpolate.pm, MV 4.04. Note: this
    # is stripped down and assumes no search label and no prefix.
    my($arg,$last);
    my $next_tag = '';
    my $prev_tag = '';
    my $q = $Vend::SearchObject{''};
    my $session = $q->{mv_cache_key};
    my $first = $q->{mv_first_match} || 0;
    my $chunk = $q->{mv_matchlimit};
    my $total = $q->{matches};
    my $next = defined $q->{mv_next_pointer}
                ? $q->{mv_next_pointer}
                : $first + $chunk;
    my $page = $q->{mv_search_page} || $Global::Variable->{MV_PAGE};
    # change this to define anchor your text
    my $prev_anchor = "B";
    my $next_anchor = "F";

    if($first) {
        $first = 0 if $first < 0;
        $arg = $session;
        $arg .= ':';
        $arg .= $first - $chunk;
        $arg .= ':';
        $arg .= $first - 1;
        $arg .= ":$chunk";
        $prev_tag .= '<A HREF="';
        my $form_arg = "mv_nextpage=$page";
        $prev_tag .= tag_area( "scan/MM=$arg", '', { form => $form_arg });
        $prev_tag .= '">';
        $prev_tag .= $prev_anchor;
        $prev_tag .= '</A> ';
    }
    if ($next) {
        $last = $next + $chunk - 1;
        $last = $last > ($total - 1) ? $total - 1 : $last;
        $arg = "$session:$next:$last:$chunk";
        $next_tag .= '<A HREF="';
        my $form_arg = "mv_nextpage=$page";
        $next_tag .= tag_area( "scan/MM=$arg", '', { form => $form_arg });
        $next_tag .= '">';
        $next_tag .= $next_anchor;
        $next_tag .= '</A>';
    }
    $Scratch->{prev} = $prev_tag;
    $Scratch->{next} = $next_tag;
    return '';
[/perl]
-
To unsubscribe from the list, DO NOT REPLY to this message.  Instead, send
email with 'UNSUBSCRIBE minivend-users' in the body to Majordomo@minivend.com.
Archive of past messages: http://www.minivend.com/minivend/minivend-list


Search for: Match: Format: Sort by: