Friday 9 May 2008

Oscommerce Adding a dropdown menu selector to catergories.php

This is a small section of a contribution that I am writing to add to the website
www.surfboardsuperstore.co.uk

The site is made with oscommerce. The problem I had was this

///////////////////FORUM///////////////////////////////////////////////////

I'm trying to write a contribution that includes adding extra value to my product tables.

I can get the code to work with an input field - but would ideally like to change this to a dropdown list. The code that is in question is



CODE





surferRecWeight); ?>




so instead of using tep_draw_input_field - i would like to use tep_draw_pull_down_menu. I know that the second arguement for the function tep_draw_pull_down_menu needs to be my array for the drop list. I have tried a couple of different ways to make the array ie


CODE
$ability_array = array('Expert', 'Average', 'Novice');


OR


CODE
$ability_array = array(0 => 'Expert', 1 => 'Average', 2 => 'Novice');


OR


CODE
$ability_array[0] ='Expert';
$ability_array[1] = 'Average';
$ability_array[2] = 'Novice';


either way I get the same result which is that the drop down list only has the first letter of my array element - 'e','a',' & 'n'.

does anyone know why. I know that the function allows strings more than one character ?



the code I am using to call up the function is



CODE
echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_pull_down_menu('surferRecAbility', $ability_array, $pInfo->surferRecAbility);

///////////////////END OF FORUM ENTRY//////////////////////////////


A very odd problem indeed, To solve this i wrote a hack ( probably very ugly) - after following the trail of the problem here the function that I needed to change was in admin/includes/functions/html_output.php and the function in question was tep_draw_pull_down_menu. so instead of messing this function up, after all every other pull down menu in admin seems to work fine! I created a new one. which is as follows

[code]

function tep_draw_pull_down_menu_two($name, $values, $default = '', $parameters = '', $required = false) {
$field = '';

if ($required == true) $field .= TEXT_FIELD_REQUIRED;

return $field;
}

[/code]

the only changes here are in $values[$i]. this is a much simplified version of what was there before, I take it because I created an array without keys etc that this is why it never worked. another solution therefore would be to rewrite the array in a format in keeping with oscommerce. However due to time constraints I will push on with the ugly hack ;)

No comments: