increasing the range for ordering attributes

Posts: 21
Joined: 03/13/2008

On my site, I have a long list of attributes for an option -- that is, a long drop-down menu -- and they need to appear in a custom, non-alphabetical order. The built-in range of -10 to 10 for the ordering field is not enough -- I have to go from -10 to 24! I can assign values larger than 10 in the database, but each time I create or edit a product, the values larger than 10 are reset to -10 and I have to do a database query to fix them again.

Is the range of the ordering field set by a variable somewhere, or is it hardcoded? I can't seem to find it. Please advise. Thanks!

Posts: 534
Joined: 08/13/2007
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.Internationalizationizer

Yeah, and I would add that I don't understand the choice of drupal about providing a dropdown list to select weight, which add nothing except limitations.

I would add a textfield instead.

Posts: 5269
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

Good point, zmove. My only guess was that it was easier to prevent mistakes. Puzzled

In any event, the only way to really address this atm is with hook_form_alter(). I don't have a snippet on hand, but you can increase the #delta value of that ordering element in the form array to get a wider range.

Posts: 21
Joined: 03/13/2008

zmove wrote:
I would add a textfield instead.

I'm not sure if you're suggesting that Drupal should have a textfield for weight, or that I should have a textfield instead of the long dropdown.

I would love to replace the long dropdown with a textfield for the attribute, if it could autocomplete with values from my option list. Is that possible with Ubercart?

Perhaps some details will help explain my situation, and maybe suggest a better solution... the attribute is the name of a congregation (church). There are more than 60 congregations in the district served by the Web site. If we use a plain text field, people will type in all kinds of things and we'll have to match them up manually with the congregations in our database. So currently the list looks something like this:

First Church, Iowa City, IA
Church of Minneapolis, Minneapolis, MN

the list has to be ordered by state and city so that people can find their churches, so if the values didn't have to be presentable, the easy solution would be something like

IA Iowa City First Church
MN Minneapolis Church of Minneapolis

That would cause the list to sort properly, but it would look terrible on nametags. So instead we're using the ordering field, with values from -10 to 24. Sad If we could get an autocomplete field, then we someone could just type

First

and every First whatever would pop up. It would be slick.

Thanks in advance for any advice you can give!

Posts: 301
Joined: 11/19/2007
Bug FinderGetting busy with the Ubercode.

While not very smooth, you might be able to fit all of your attributes into the -10 to 10 range if you take advantage of any two alphabetically sequential attributes being sorted correctly when sharing the same weight.

Posts: 4
Joined: 08/01/2008

Alphabetical ordering does not seem to be working. I downloaded a module to increase the weight range and it works prefectly. You can find it in here: http://drupal.org/node/117274#comment-944650

Posts: 17
Joined: 07/08/2008

Do you have a link to your site? Maybe a solution can be found if we could see exactly how you have things set up.

Posts: 21
Joined: 03/13/2008

Thanks, Smeghead! I'll give that a try.

Jumonjii, the site in question is https://secure.bluehost.com/~psduuaor/ubercart/ . The "PSD Congregation" field is the one that needs a larger weight range.

--Ben