Zen Cart Logo
Forums / Setting Up Categories, Products, Attributes / Can dropdown boxes be rescaled?

Can dropdown boxes be rescaled?

Locked

Views: 1,441

Results 1 to 5 of 5
This thread is locked. New replies are disabled.
14 Mar 2008, 7:46 PM
#1
htsean avatar

htsean

New Zenner

Join Date:
Mar 2008
Posts:
50
Plugin Contributions:
0

Can dropdown boxes be rescaled?

I have about 30 attributes inside of a single dropdown box in my product page. So now when I pull down the dropdown box, there is a very long list of attribute choices.

Is it possible to add code to the dropdown box so that it remains a constant size, displaying only 5 items max and the rest through scrollbars?

15 Mar 2008, 12:32 PM
#2
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: Can dropdown boxes be rescaled?

Selection boxes can work in two different ways. Either as a dropdown menu that starts as a single line and expands, or as a fixed number of lines with a scroll bar.

For Zen Cart attributes the code dictates that the options are displayed as a dropdown menu. It would be possible to tweak the code to define a size (i.e. number of rows) to change this to a scroll box. You would do this by over-riding the includes/modules/attributes.php file to add the code highlighted in red below, where xxx is the number of rows that you want. You'll find this code at about line 595 in Zen Cart 1.3.7 or 1.3.8> $options_menu[] = zen_draw_pull_down_menu('id[' . $products_options_names->fields['products_options_id'] . ']', $products_options_array, $selected_attribute, 'id="' . 'attrib-' . $products_options_names->fields['products_options_id'] . '" size="xxx"') . "\n";Note, though that this will change all dropdown menus used for displaying attributes. If you wanted to restrict this change to a particu;ar attribute, you would need to insert some conditional code based on the products option id.

16 Mar 2008, 7:32 AM
#3
htsean avatar

htsean

New Zenner

Join Date:
Mar 2008
Posts:
50
Plugin Contributions:
0

Re: Can dropdown boxes be rescaled?

thank you kuroi. The designated size of the attribute box is what I wanted and the code worked out nicely. :smile:

Do you think it is possible to add an option in the product view to let the customer switch styles of the attributes from a fixed box with scrollbars to a checkbox?

16 Mar 2008, 9:28 AM
#4
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: Can dropdown boxes be rescaled?

I guess they could. It would require a number of tweaks, but here are the two most important to get you started.

Go back into your override version of the attributes.php module and find the folowing at about line 177

// prepare product options details
$prod_id = $_GET['products_id'];
//die($prod_id);
```Immediately afterwards add```php
if ($_GET['checkboxes'] && $products_options_names->fields['products_options_type'] == 0 ) {
  $products_options_names->fields['products_options_type'] = PRODUCTS_OPTIONS_TYPE_CHECKBOX;
}
```Then find the following (now at about line 597)```php
$options_name[] = '<label class="attribsSelect" for="' . 'attrib-' . $products_options_names->fields['products_options_id'] . '">' . $products_options_names->fields['products_options_name'] . '</label>';
```and extend it to```php
$options_name[] = '<label class="attribsSelect" for="' . 'attrib-' . $products_options_names->fields['products_options_id'] . '">' . $products_options_names->fields['products_options_name'] . '</label>' . '<a href="' . zen_href_link(FILENAME_PRODUCT_INFO, 'cPath=' . $_GET['cPath'] . '&products_id=' . $prod_id . '&checkboxes=1') . '">click to show as checkboxes</a>';
```This will work but is most likely just a beginning. You would also want to style the link, the option titles (or at least this one to give it a line of its own) and the checkboxes. The link text should really be moved into a language file. And you may wish to restrict this visitor option to a particular products or even specific option by tweaking the first change, and make it persistent by recording use of the link in a session variable or cookie and using that in the first condition instead of using the $_GET parameter directly.
28 May 2008, 2:25 PM
#5
guls_guys avatar

guls_guys

New Zenner

Join Date:
Apr 2008
Posts:
25
Plugin Contributions:
0

Re: Can dropdown boxes be rescaled?

Thanks Kuroi
for pointing out the option_menu[] code fragment. it solved many problems for me. added style="width:150px"; to increase the width of the option menu.
thanks.
i tried to increas the character size and display in the arrtibue controller but it did not worked so had to do manually.

but still work searching

regards
salman