App-ZofCMS
view release on metacpan or search on metacpan
lib/App/ZofCMS/Plugin/SplitPriceSelect.pm view on Meta::CPAN
=head3 C<options>
options => 3,
B<Optional>. Takes a positive integer as a value. Specifies how many price ranges (i.e.
C<< <option> >>s) you want to have. B<Note:> if there are not enough prices
in the C<prices> argument, expect to have ranges with the same price on both sides; with
evel smaller dataset, expect to have less than C<options> C<< <option> >>s generated.
B<Defaults to:> C<3>
=head3 C<t_name>
t_name => 'plug_split_price_select',
B<Optional>. Plugin will put generated C<< <select> >> into C<{t}> ZofCMS Template special key,
the C<t_name> parameter specifies the name of that key. B<Defaults to:>
C<plug_split_price_select>
=head3 C<name>
name => 'plug_split_price_select',
B<Optional>. Specifies the value of the C<name=""> attribute on the generated C<< <select> >>
element. B<Defaults to:> C<plug_split_price_select>
=head3 C<id>
id => 'plug_split_price_select',
B<Optional>. Specifies the value of the C<id=""> attribute on the generated C<< <select> >>
element. B<Defaults to:> C<plug_split_price_select>
=head3 C<dollar_sign>
dollar_sign => 1,
B<Optional>. Takes either true or false values. When set to a true value, the C<< <option> >>s
will contain a dollar sign in front of prices when displayed in the browser (the
C<value="">s will still B<not> contain the dollar sign, see C<PARSING QUERY> section below).
B<Defaults to:> C<1>
=head1 PARSING QUERY
plug_split_price_select=500-14000
Now, the price ranges are generated and you completed your gorgeous form... how to parse
those ranges is the question. The C<value=""> attribute of each of generated C<< <option> >>
element will contain the starting price in the range followed by a C<-> (dash, rather minus
sign) followed by the ending price in the range. B<Note:> the price on each end of the
range may be the same if there are not enough prices available.
Thus you can do something along the lines of:
my ( $start_price, $end_price ) = split /-/, $query->{plug_split_price_select};
my @products_in_which_the_user_is_interested = grep {
$_->{price} >= $start_price and $_->{price} <= $end_price
} @all_of_the_products;
=head1 GENERATED HTML CODE
This is what the HTML code generated by the plugin looks like (providing all the optional
arguments are left at their default values):
<select id="plug_split_price_select" name="plug_split_price_select">
<option value="200-1000">$200 - $1000</option>
<option value="4000-6000">$4000 - $6000</option>
<option value="7000-7000">$7000 - $7000</option>
</select>
=head1 REPOSITORY
Fork this module on GitHub:
L<https://github.com/zoffixznet/App-ZofCMS>
=head1 BUGS
To report bugs or request features, please use
L<https://github.com/zoffixznet/App-ZofCMS/issues>
If you can't access GitHub, you can email your request
to C<bug-App-ZofCMS at rt.cpan.org>
=head1 AUTHOR
Zoffix Znet <zoffix at cpan.org>
(L<http://zoffix.com/>, L<http://haslayout.net/>)
=head1 LICENSE
You can use and distribute this module under the same terms as Perl itself.
See the C<LICENSE> file included in this distribution for complete
details.
=cut
( run in 1.115 second using v1.01-cache-2.11-cpan-39bf76dae61 )