[ic] Modifications to Selected and Checked Coretags

Mat Jones mat at thinkopensource.com
Thu Oct 16 18:50:19 EDT 2003


I have made some minor modifications to the [selected] and [checked] coretags (4.9.8) to allow a 
delimiter="" option to be specified. If delimiter="foo" is used then multiple="1" is assumed and not 
required. The tag is backward compatible, so anyone currently using multiple="1" will not have any 
issues.

Example usage (with a comma delimited list):

<select name="mail_list" MULTIPLE>
<option value="newsletter" [selected name="mail_list" value="newsletter" delimiter=","]>newsletter
<option value="upgrade" [selected name="mail_list" value="upgrade" delimiter=","]>upgrade
</select>

The diffs are below. Hope its of some use :)

Mat

------------------------------------------------------

*** selected.coretag.old        Thu Oct 16 21:32:07 2003
--- selected.coretag    Thu Oct 16 20:39:39 2003
***************
*** 19,27 ****

         return ' SELECTED' if $ref eq $value;

         if ($opt->{multiple}) {
                 my $regex = quotemeta $value;
!               return ' SELECTED' if $ref =~ /(?:^|\0)$regex(?:$|\0)/i;
         }

         return '';
--- 19,32 ----

         return ' SELECTED' if $ref eq $value;

+         if ($opt->{delimiter}) {
+                 $opt->{multiple} = 1;
+         }
+
         if ($opt->{multiple}) {
+               my $delimiter = Vend::Interpolate::get_joiner($opt->{delimiter}, "\0");
                 my $regex = quotemeta $value;
!               return ' SELECTED' if $ref =~ /(?:^|$delimiter)$regex(?:$|$delimiter)/;
         }

         return '';

------------------------------------------------------

*** checked.coretag.old Thu Oct 16 20:41:54 2003
--- checked.coretag     Thu Oct 16 20:35:48 2003
***************
*** 19,27 ****

         return ' CHECKED' if $ref eq $value;

         if ($opt->{multiple}) {
                 my $regex = quotemeta $value;
!               return ' CHECKED' if $ref =~ /(?:^|\0)$regex(?:$|\0)/i;
         }

         return '';
--- 19,32 ----

         return ' CHECKED' if $ref eq $value;

+       if ($opt->{delimiter}) {
+               $opt->{multiple} = 1;
+       }
+
         if ($opt->{multiple}) {
+               my $delimiter = Vend::Interpolate::get_joiner($opt->{delimiter}, "\0");
                 my $regex = quotemeta $value;
!               return 'CHECKED' if $ref =~ /(?:^|$delimiter)$regex(?:$|$delimiter)/;
         }

         return '';

------------------------------------------------------



More information about the interchange-users mailing list