[ic] accessories tag

Brent Kelly interchange-users@icdevgroup.org
Sun Jan 19 17:02:01 2003


Hi Schuyler,

I struck a similar problem when I had matrix options & wanted to display 
them in a customised fashion. The only way I could get the accessories 
tag to return anything was if I used the code from the options table 
that correlates to the option values you are wanting to retrieve 
(confused yet? ;)). This code is not the same as the sku in the products 
table, but appears to be generated when you create the options (not sure 
if u can specify this - mabye you can). If you look at the database 
directly, you will see this as a record with the sku field being set to 
the product sku, the o_label field being set to the label you specified 
for the options, and the o_value field being of format 
value=label,value2=label2 etc.

So basically, I ended up using the following ... a bit of a workaround, 
but hey, it works :):

First i retrieved the option code from the db with the query tag (note 
this assumes you have specified & know the label for the options .. if u 
don't i'm sure the code could be retrieved by a modified query):

[perl no_return=1 interpolate=1]

   # retrieve the option code for the options I am wanting[/comment]
   my $results = $Tag->query( { sql => "SELECT code FROM options WHERE 
o_label='Color' AND SKU = '[item-code]'" } );   
   $Scratch->{option_code} = $results->[0]->[0];

[/perl]

If you retrieve the o_value field from the options table using the 
returned code, you get the following format:
R=Red*, O=Orange, Y=Yellow

 From here, depending on what you are trying to do, you can now use the 
accessories tag to acheive what you wish.

e.g.

[accessories
      code="[scratch option_code]"
      table="options"
      field="o_value"
      name="mv_sku"
      js=| onchange="alert('size change');" |
      type=select
]

that would spit out a select box populated by the options & would cause 
a javascript alert onchange. Note: if you use type="show" it seems to 
merely spit out the o_value (R=Red*, O=Orange etc). However, changing 
the type to labels would spit out a newline-delimited list of the option 
labels which sounds like what you're after.

Alternatively if you wanted to be able to display these one at a time 
(allows you to format them how you wish & specify match/no_match code) 
you may just want to use a loop (acclist=1) and use the data tag to 
retrieve the options as the list attribute for the loop. i.e:

[tmp count]1[/tmp]
[loop list=|[data table="options" field="o_value" key="[scratch 
option_code]"]| acclist=1]
   [list]
      <b>Option [scratch count]:</b> [loop-param label]<br>
      [perl no_return=1]$Scratch->{count}++[/perl]
   [/list]
   [no-match]No options![/no-match]
[/loop]

As you can see its nowhere near as pretty as a one-liner accessories tag 
call, but it was the only way I could acheive the results I wanted (or 
manage to get anything out of the tag for that matter :)).

If anyone out there has a better way that works, feel free to enlighten 
us :).

Hope this helps,

Brent Kelly,
Zeald Ltd.
http://www.zeald.com



Schuyler Langdon wrote:

>I wrote
>  
>
>>I have matrix options (ic 4.86) for products that can be displayed as a
>>select menu with the following tag:
>>[options code=os28005]
>>
>>However, I want to use an accessories tag something like this so
>>that they can simply be listed.
>>[accessories code=os28005 table=options type=show]
>>
>>This does not work though, does anyone know if or how this can be done
>>    
>>
>using
>  
>
>>the accessories tag?
>>
>>    
>>
>
>Simple tag question, Anyone, Bueller ?
>
>Schuyler Langdon
>GatorDev.com
>
>_______________________________________________
>interchange-users mailing list
>interchange-users@icdevgroup.org
>http://www.icdevgroup.org/mailman/listinfo/interchange-users
>
>  
>