Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi again,
Could the weight module somehow be used with views?
I tried sorting by stickiness on a new view, but nothing happened.
Thanks in advance!
Comment | File | Size | Author |
---|---|---|---|
#31 | weightviews.patch | 5.99 KB | sheise |
#27 | changes.patch | 5.98 KB | Jody Lynn |
#24 | weight.patch | 658 bytes | Jody Lynn |
#20 | weight-views-3.patch | 13.19 KB | Jody Lynn |
#16 | weight-views-complete-2.patch | 13.05 KB | Jody Lynn |
Comments
Comment #1
NancyDruDue to the massive changes in Views, it may be a while before I can figure out what to do. If someone wants to submit a patch, I would be very happy.
Comment #2
chasz CreditAttribution: chasz commentederhmm, CCK will get you into views
Comment #3
libeco CreditAttribution: libeco commentedI don't really understand what you mean. Can I sort by weight through cck and views?
Comment #4
NancyDruThe weight is part of the sticky field and it may work correctly with Views2; I just have not had enough time to find out. In 5.x, special Views code had to be added to make it work correctly and I have not had the time yet to try to rework the Views code, which is not my forté.
Comment #5
libeco CreditAttribution: libeco commentedSorry, I was referring to chasz' comment. I tried weight in views and didn't really get it to work in D6.
Comment #6
Jody LynnSorting by stickiness seems to be working for me with Views 2, however it is necessary to make the sort order DESC rather than ASC to get the desired ordering.
Comment #7
NancyDruSticky should be descending. Unencoded sticky is 1 and unencoded non-sticky is 0, so you would want the 1's first.
I'm glad it's working. It does sound like perhaps an issue against Views might be in order though.
Comment #8
Jody LynnI created a views integration for the module. It includes a Weight field which displays the weight, a Weight sort (which allows you to order by Weight ASC which I think is more intuitive but is the same as ordering by Sticky DESC), and best of all a new style plugin called 'Weight Changer'.
The idea is that you can set up a view using the 'Weight Changer' style and include the Weight field and Sort by Weight ASC. The resulting view is a form displayed as a table with drag and drop for updating the weights. This is working for me so far in my testing.
I'm attaching a patch with changes to weight.views.inc and weight.module and a zip file which contains additional files (handlers for views and a template file for the style plugin.)
Comment #9
NancyDruWow, thanks, Jody! This is fabulous. I don't suppose you also have a patch that increases the number of hours in a day?
Comment #10
lyricnz CreditAttribution: lyricnz commentedHave you looked at http://drupal.org/project/draggableviews? This can already be used to reorder records based on a CCK field (or non-CCK if they extend it http://drupal.org/node/317400).
Comment #11
mitchell CreditAttribution: mitchell commentedCould you please post screenshots?
Comment #12
chasz CreditAttribution: chasz commentedthey have a demo over there.
if you want weight in views....then just create a normal numerals dropdown CCK field and and use the views to order it by ASC or DESC
this is for people who dont use views or waiting for views to mature a bit
Comment #13
gddI got this running today, it was just what I needed for a client project. One thing I noticed is that the draggable view does not appear in Views' preview area. Is this by-design, a bug, or user error? It confused me for a good while since I thought that I had screwed something up in my View.
I also tried draggable views and never got it to work.
Comment #14
gddI did find one problem. In weight-view-weight-form.tpl.php, line 15 throws a notice on every instance of $row, because it tries to look up 'nid_hidden' in $fields and it doesn't exist. This file is in the zip, so I don't really know how to patch it, but you should replace line 15 with
To get around the problem.
Comment #15
populist CreditAttribution: populist commentedthis patch is flat cap awesome.
rerolled as a single file using some cvs voodoo, the php notice talked about in #14 is resolved, and i moved the drupal_add_tabledrag() callback to the _form() function instead of the template (so people can override as needed).
Comment #16
Jody LynnI moved the hook_theme into weight.module rather than weight.views.inc because I think having it in the inc was causing some problems related to theme registry (could be involved in the #13 issue.)
Also added a little to populist's help text
Comment #17
NancyDruThanks for the patches. I'm back from vacation, so as soon as I find my brain again, I'll test them.
Comment #18
pfournier CreditAttribution: pfournier commentedCould you add the following code in weight_views_data() (file weight.views.inc), at the end of $data['node']['weight']
This would enable filtering by weight.
(I am too lazy to resubmit the whole patch)
Thanks
Comment #19
virtualdrupal CreditAttribution: virtualdrupal commentedI just wanted to chime in that I ran the patch from past #16 and was not given the option to sort by weight in views 2, it DID seem to fail on the very last line of the patch with patch: **** malformed patch at line 424:.
Refreshing cache and rescanning templates didn't help. So I started fresh and tried to patch using the files in post #8 and now 'sort by weight' is an option and everything works great.
Thanks for the patches by the way, this module is exactly what I needed...
Comment #20
Jody LynnHere's a rerolled patch to correct the patch problem reported in #19 and add the filter from #18.
Comment #21
NancyDruMarked #319479: i can't make it run on my views as duplicate.
Comment #22
NancyDruPatch failed on line 339.
I manually created the new files and removed them from that patch and it applied.
However, I get "Error: handler for node_weight > weight doesn't exist!" (Yes, I cleared the Views cache.)
Comment #23
NancyDruIt has been committed, so an incremental patch would be needed.
Comment #24
Jody LynnIt's because the handlers were previously in a separate handlers subdirectory. If you don't want to have that subdirectory then just change the path in this function as so to not include 'handlers':
(patch attached)
Comment #25
NancyDruThanks, that did the trick.
Comment #26
SofiaSund CreditAttribution: SofiaSund commentedHi thanks for this patch! It mostly works well on my test site, but every now and then when I make changes or move between pages I get the following warning messages and my weight-view disappears:
On my current installation I'm using a page view which works fine, but the warning messages show up as soon as I enable SimpleMenu and disappear as soon as I disable it.
On a previous installation, it seemed to be more random - the same block view was showing correctly on some pages but gave me the warning messages on others.
I'm rather new to Drupal and I don't really know where to start looking. Does anybody know what the problem could be and what could be a possible solution?
Thanks, Sofia
Comment #27
Jody LynnA couple of tweaks to fix SofiaSund's issue, and I also moved the template_process function into weight.module as it was not always loading for me from within the views.inc.
Note this is now a patch on HEAD.
Comment #28
SofiaSund CreditAttribution: SofiaSund commentedThanks a million!
Comment #29
NancyDruResetting status.
Comment #30
tancThis is great, thanks for writing the patch Jody. It appears to work very nicely in all regards in my testing so far. The only thing that seems to need some attention is the views templates.
Currently if you look at 'Theme: information' in Views 2 you'll notice that an expected template file is missing: weight-view-weight.tpl.php (File not found, in folder sites/all/modules/weight/). From what I can tell this file is needed if a themer wants to override a table row in their theme folder.
Any chance you can abstract the necessary data from weight-view-weight-form.tpl.php into a weight-view-weight.tpl.php file? Without this I'm not sure how to theme my table rows.
Thanks!
Comment #31
sheise CreditAttribution: sheise commentedI have rerolled the patch in comment #27 for HEAD.
Comment #32
NancyDruCommitted.
Comment #34
giginos CreditAttribution: giginos commentedNote: Activateing the "Weight" ist quite hidden. You can activate the "Weight" in the Tabs of the Content types.
Link: /admin/structure/types/manage/article