Hi Peter,
I've added in some table drag support on the overview page so that the ordering of related content is user-definable, using the same mechanism as Drupal Menu module uses. There is currently no way to change the order in which related content appears, unless I guess you use Views in some way? Unless I've overlooked something?
Anyway I noticed that the ordinal_number isn't actually very important, as long as nodes that are related are ordered in some way - the values might be 1,2,3 or 1,45,235 for all it matters.
I've only modified a couple of functions to add in the table drag functionality.
Would this be a useful addition? If so, how do I supply my changes?
Ian.
Comment | File | Size | Author |
---|---|---|---|
#17 | relatedcontent_662186_table_drag_17.patch | 8.51 KB | dooug |
#7 | relatedcontent-dnd-full.tar_.gz | 34.84 KB | ian-g |
#4 | relatedcontent-withdragndrop.zip | 15.72 KB | ian-g |
Comments
Comment #1
vir_2 CreditAttribution: vir_2 commentedHi Ian,
I'm very interested in this feature.
Can you please post your patches?
cheers,
volker
Comment #2
peter-boeren CreditAttribution: peter-boeren commentedHello Ian,
that is most welcome. Maybe you can archive the module and send it by e-mail or attach it to a post. The D5 version had the possibility to add weights but I never had enough time to dig into the drag and drop functionality myself. I'm looking forward to your contributions.
Peter
Comment #3
Leumas CreditAttribution: Leumas commentedHello
I think I found a solution to have custom ordered nodes for RelatedContent. It doesn't require any change on the module. Instead it uses another module to achieve the desired result of having drag and drop to order RelatedContent nodes.
The extra module I'm using is called DraggableViews. Very briefly this module allows you to order nodes from a view using drag and drop. Since in RelatedContent "the selected nodes are decoupled from the source from which they were selected" (see documentation section Decoupling) you can first specify a node order for the view and then select the related nodes. Even if you reorder the view afterwards, RelatedContent will display related nodes ordered as specified the first time.
I tried this for only a couple of hours and it seems to work quite well for what I need: a newsletter (using Simplenews) with a list of related custom ordered nodes. I created a view that lists my articles. Then I dragged and dropped the nodes to specify a display order. Finally I created a newsletter and selected the nodes I want to send using RelatedContent.
So I guess I'll use this new method for my next month newsletter.
Cheers,
Sam
Comment #4
ian-g CreditAttribution: ian-g commentedSorry for the delay, being Christmas and all.
I've updated my changes to work on the current release (I had base-lined it from a July 2009 release).
I'm not sure how to create a patch file to work across 2 files (I've modified the .module and .theme.inc files), so I just attach them both here.
I'm sure there is a better way of doing some of my changes, but feel free to modify anything, and maybe incorporate into a new release at some point.
The interesting functions that I've changed are identified with my username (ian-g) so a simple diff on the current release and my modified file should highlight the changes. Essentially I change the functionality slightly if its the overview page...
cheers,
Ian.
Comment #5
peter panes CreditAttribution: peter panes commentedThis would be exactly what i need but i cant get it to save, the drag and drop works but when i hit update all the related nodes disappear.
Comment #6
ian-g CreditAttribution: ian-g commentedHi Peter,
I'm just about to install this module on a new site here, so I'll check it out and make sure I didn't miss anything when I uploaded my tweaks...
I'll report back later today.
Ian.
Comment #7
ian-g CreditAttribution: ian-g commentedI've just deployed this to a new site I'm working on, and it all worked fine.
I do display the related nodes in the right sidebar via a custom theme function, but my block is based on the more advanced example given in the documentation. I paste my custom block below, and attach the full module with my tweaks.
Comment #8
peter-boeren CreditAttribution: peter-boeren commentedthanks ian-g for the effort. For me the holidays were also a break for Drupal. I'll look into it a soon as I have some open-source-spare-time.
to be continued!
Comment #9
peter panes CreditAttribution: peter panes commentedI have uninstalled the module completely and reinstalled with the 2 additional files. I still have the same problem, on attempting to save the new order by clicking the Update button, it empties the relatedcontent table and the related nodes are lost.
I have no idea whats going wrong.
Comment #10
peter panes CreditAttribution: peter panes commentedI have found the following error, i assume its something to do with my version of MySQL, any ideas:
user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '),(17,'6',40,),(17,'6',39,)' at line 1 query: INSERT INTO relatedcontent (nid, vid, include_nid, ordinal_number) VALUES (17,'6',38,),(17,'6',40,),(17,'6',39,) in ......\includes\database.mysqli.inc on line 128.
Comment #11
peter-boeren CreditAttribution: peter-boeren commentedPeter, It is not your mysql version. The values expect 4 columns to fill but only three real values are given. There is a ',' for the the fourth value (ordinal number == weights/position) but it is not filled. I believe that this indeed would trigger an error message in mysql.
Comment #12
peter panes CreditAttribution: peter panes commentedYep thanks i see that now, so I'm assuming its not filling the array correctly, could this be an incompatibility with another module?
I think ill start with a fresh installation and keep adding modules until it stops working.
Comment #13
peter-boeren CreditAttribution: peter-boeren commentedNo it is relatedcontent specific.
Comment #14
peter panes CreditAttribution: peter panes commentedI'm totally stuck on this, it works on all my other sites but not the one i want to put it on. this is the site i want to use it on www.ccn.ac.uk.
Anyone got any ideas why it doesn't work on this site?
Comment #15
ian-g CreditAttribution: ian-g commentedHi Peter and Peter,
Is this related to my changes? If so I guess its up to me to sort it... I'll have a look and see what I can find.
cheers,
Ian.
Comment #16
ian-g CreditAttribution: ian-g commentedHi again,
Off the top of my head, the function that might be the cause is this function:
if somehow my
$newOrderings
array isn't getting the correct data, then the array of 4 values is missing the 4th value. Peter (Panes) - can you add in some debug info, such asdpr($newOrderings);
if the devel module is enabled, or just useprint_r($newOrderings);
otherwise. Perhaps also show the$values
array too after theif/else
block, and see what data is being passed in to the function.It might be that
$newOrderings
is not null, but is empty, and so the process flow goes into myelse
block, and its setting the 4th parameter as non-existant.Why this might be, I'm not sure... But its a possibility.
I'm pleased it works on your other sites though :)
cheers,
Ian.
Comment #17
dooug CreditAttribution: dooug commentedHey all,
I also need table drag support for the related content module. I tested ian-g's posted tarball of the module and was getting the same errors reported by peter-panes in comment #10.
I investigated and found that ian-g's code would only work if the view that populates the Overview table is has $vid = 1 (the view id) in the _relatedcontent_form_submit function.
I fixed the code and it is working as expected. However, while I was debugging, I noticed the code should probably be reworked to adhere to the Drupal coding standards. (Kudos to the original developers/maintainers for the excellent code documentation in this module.) I'd also like to see the feature to drag and order each View group on the Overview table. Additionally, the nodes can be dragged to a view group that they are not a part of, and when updated this is ignored. That could be improved to prevent confusion.
I'll continue to try to improve this feature as I find the time. Until then, here is the latest working patch. Please test and review it.
Comment #18
CodigoVision CreditAttribution: CodigoVision commentedGreat patch thanks. The table looked a little strange at first as the handle and the check box are in the same column, the check box was overlapping the title column. here is my quick css fix in case anyone has the same problem.
Also it would be great if grouping by view was optional so it could be turned off and have full ability to order the content.
www.codigovision.com