By littleprince on
As the title says, anyway to increase the granularity of the weight range? It is quite limiting, and hard to use compared to some other CMS.
Values from -100/100 would be useful.
Is this something that can be changed site wide? Or is it module specific?
Comments
Totally agree
I agree. When creating custom content types with many fields, it is impossible to order the fields properly as there are more fields than weights available.
No more weights
Due to the "Personal battle plans for Drupal 6" http://drupal.org/node/111140, quicksketch is planning "to work on jQuery based weights in tables (drag and drop). Finally we'll be able to rid ourselves of the awkward 'change the weight, refresh the page' workflow we've been using for so long."
Steve McKenzie also announced to work on "Drag n Drop for Core (Weight Value sorting on Menus, Taxonomy, Blocks, Profile Fields and region sorting on Blocks)."
Maybe this could help your needs.
Drag and Drop for Core would be great
Drag and Drop for Core would be great. I guess we will just have to wait for Drupal 6 to come out, make ado and be patient for a while.
Using Drupal 6 for a production site is not for tomorrow
In the meantime, where in Drupal's core code can these limits -10, +10 be changed ?
Are these hard-coded on a per module basis ?
Caroline
11 heavens
re: where in Drupal's core code can these limits -10, +10
I'm pretty new to Drupal myself so I don't quite know the ins and outs of it just yet.
There's probably an easier way to get this done..but here's my solution. More of a hack really...
I added a line inside function process_weight($element) found in line 1488 of the core file: includes/form.inc
add this line before the for($n= (-1 ... ) loop:
Hope this helps...
re: where in Drupal's core code can these limits -10, +10
I used your hack and used it to sort fields in a custom content type and at first it seemed to work fine (more weight options available) but after updating the fileds' weights in fields management, fields with weight more than 10 disapeared from the list! The fields were not lost of course, they just don't show up in that list.
Furthermore, while adding content of this content type the fields with high weights seem to get mixed up with the default form items that are present at the bottom of the page (Comment settings, menu settings, etc). Maybe the reason drupal limits the custom weights from -10 to 10 is to leave space for default or module created items.
To recover i hade to change the weights manualy in the node_field_instance table
Hmmm, it seems a quick way
Hmmm, it seems a quick way that increase site-wide weight range. My poor way to hack taxonomy.module, just need to extend term weight.
- line 421
Have any good idea to do?
Agree with weight increasing
we are using book module on our site, as you all know, some books have more than 31 chapters 8-(
Weight Range can be extended in Book module
In books module weight field is tinyint which supports -128 to +127
What you need to do is make some small cjange in "book.module" file available "module/book" folder.
*Hints-
Opne the file and change all instance of " '#delta' => 15 " to " '#delta' => 127 "
That will bring a weight range -127 to +127
Thats all. works fine for me.
-Barnamala
so it can be done?
does this mean it can be done for all the other modules as well with the same kind of hack? (4.7)
Authentically,
BassPlaya
Very simple and worked
Very simple and worked beautifully... thank you VERY much!
Still works
Just to let people know that this fix still works as of 12/2009 in Drupal 6. Thanks! This really should be a setting administrators/users can change without editing the book.module file.
Edit the module
When I've needed more, the only option I could find was to go in and manually edit the module.
I have only done this on the forms module (for 4.7 and earlier), so I can't tell you off hand where to find it in the other modules.
--
Jenni S.
ok
I'll give it a try and let you know.. thanx for the reply !!
Authentically,
BassPlaya
Anyone figure this out?
Hi folks,
Very interesting discussion here.
Anyone figure out a way to make these weights be more versatile?
can't find delta tag..
I can't find the delta thing in for example the node.module and the word weight is there a 100 times.. I really don't know which one is responsible for the range of the weight. Hope someone else can find out.
Authentically,
BassPlaya
=-=
weights can be extended using the weight.module in the downloads area.
subscribed
interesting topic
very strange that this isn't fixed yet
--
Italian drupaler
This is what I did...
I used both patches posted above, but to clarify I will repeat the code modifications with a bit more info.
Find this code around line 1494 in /includes/form.inc:
and replace/modify to match this:
and replace/modify it to match:
and replace/modify to match:
Notice the value at the end,.. I changed from 10 to 100,.. so that all the fields and groups with a weight higher than 10 will be shown when editing them.
Final Step
Here comes the tricky part.
You will probably need to change all the default weight values to something higher.
I downloaded my entire web dir and opened it in TextMate (a powerful text editor for the mac, Ultra Edit works well for windows) and did a global search & replace.
I searched for:
'#weight' => 25and replaced with:'#weight' => 65adding 40 to the initial weight. You must do this for all the default values.I would suggest starting at the highest weight value: 100 and working your way down so you don't enter an infinite loop :). I found that 100 was used as the maximum and it seemed to skip the range until 50. You don't need to search for every incremental value, but the key ones seem to be numbers divisible by 5 (25, 30 etc) and numbers ending in 9.
Be careful modifying weights around and below 10. I'd suggest doing this on a per instance basis.
Oh and of course, always backup your code before changing -anything- :)
another way
There is an easier way, built into drupal, to allow you to increase your weighting list.
And can be implemented per each form if desires.
Create a new module and add this function...
Change the
<modulename>with the name of your module and this will increase the weight limits from 10 to 33.Web Developer : RockRiverStar.com : Philadelphia, PA
Technical Architect : Philadelphia, PA
this code does not work for me
I have added you code but nothing happens to the weight limits.
I tried to set the $form_id to the cck type form id. I also tried without the if statement...
The
$form['weight']['#delta']is being set but nothing happensSo far, this works for me in 5.7
Changed line 72 of system.module from
to:
This is a global change to the delta, affecting all 'weight' inputs in all forms, but as far as I'm concerned, that's a good thing.
I've tested it a bit, and it does rearrange the form as I think it should, and the display mirrors the form order. No adverse effects that I've noticed; I will post back here if I see any.
I can imagine it might cause some problems if you ever decided in the future to lowerthe delta. Along the same lines, if you forgot to bring this hack forward when you upgraded to 6 or 7, I imagine there might be a price to pay.
following...
following this thread - thx
Scott Rigby
http://basekamp.com
http://PlausibleArtworlds.org
http://UtopiaSchool.org
Works for me
Thanks zbricoleur, It works well for me! (i'm using 5.7 too)
A tiny helper module
Wrote a tiny module. Hope it could help.
http://remarka.ru/drupal/weight_range-5.x-0.1.tar
I installed and enabled your
I installed and enabled your module, but I cannot figure out how it works. How do you set a new weight range?
edit: never mind, the module automatically extends the weight range as soon as it is enabled: -30 to +30, and works prefectly. I expect you could change the number 3 in this line for a larger range: $element['#delta'] = $element['#delta'] * 3
Thanks!
Perfect
@whisk, this is a great example of a simple module that is very useful (for 5.x sites)
Thank you for making this available. It works great.
Did not worked well
It Added the weights. But When I submitted the form all the fields got disappeared.
Use Groups to group your fields
I tried one of the above tips increasing the range from 10 to 30, but it didn't work in CCK. If I selected for example weight 12 the field wouldn't show up under Home » Administer » Content management » Content types » Manage fields
It turns out the simple solution and working _with_ Drupal is the way to do it 8o)
Just remember to configure how fields and field labels should be displayed when it's viewed in teaser and full-page mode under "Display fields" before you group them, since they are locked when grouped.
Drupal 6?
Can anyone point me to a solution for drupal 6?
i need it to set the right order for cck fields in a views 2 view with more than 50 fields.
weight_range patch for Drupal 6
I was able to get the weight_range module above working in Drupal 6 by making the following changes:
In weight_range.info, define
In weight_range.module, change line 9 to
Enjoy!
Drupal 6 module (not yet contributed)
Here is a working copy of the Drupal 6 module, complete with admin settings screen. I've applied for a CVS account so I can contribute it properly.
http://interdependentweb.com/weight_range.zip
thank you
sounds good, will try it now.
Edit: Works perfect. just it does not show me an option in the menu, but the url is not easy to find when i look into the module.
Works for me. Nice one.
Works for me. Nice one.
--
Tom
www.systemseed.com - drupal development. drupal training. drupal support.
Typo in your hook_menu,
Typo in your hook_menu, MENU_NORMAL_ITEM not MENU_LOCAL_TASK.
Did ya ever get a CVS account for this?
Reply to comment Need bigger weight range!
thank u so much. It works for me
increase the weight for book module in drupal 6.19
opened modules/book/book.module at line 389 '#delta' => 15 I changed the value to 100 and it worked.
sunil datta
www.opensourcenuts.com
Drag and Drop
@sunil_datta's suggestion works, but only in the drop-down menu. The drag and drop function of reordering still won't reorder the pages.
Default range of weight to modules
Exist default range of weight to modules?
If yes, what's the default range of Weight? -100 and 100?