Nodeorder should use whatever hook to get the field sortable using views so that sorting is possible for list views and such.

Comments

webavant’s picture

I guess I am requesting this module act more like the weight module, which does not have the move up/down capabilities that nodeorder has.

petterw’s picture

Status: Active » Needs review
StatusFileSize
new989 bytes

I've put together a views include file that adds nodeorder as a sort criteria.

Drop it in your views/modules folder. I had to wipe my views installation completely for views to pick it up http://drupal.org/node/64165

Instead of being implemented as a views include I assume this code could be added as a patch to nodeorder.module directly.

webavant’s picture

Yes! That is awesome! You are awesome!

webavant’s picture

Hmm... I added the include and wiped the views module completely, but nodeorder is not showing up in the sort criteria for views.

webavant’s picture

hmmm... I can't get it to work. Shouldn't there be a require statement somewhere to pick it up? Where is the nodeorder_views_tables() function called?

bonobo’s picture

Assigned: Unassigned » bonobo
Status: Needs review » Closed (works as designed)

At first glance, this feature request doesn't apply to this module -- the nodeorder module allows for drag and drop ordering of nodes within taxonomy terms -- you can use this module to specify the order in which nodes display within taxonomy terms -- I'm not entirely clear how/what you would want to expose to views -- can you be more specific?

In the meantime, until this is clarified, I am marking this "by design."

bonobo’s picture

Status: Closed (works as designed) » Needs review

I just re-read the thread, and I think I get it now --

whoops!

You want the ability to sort nodes that appear within views, in addition to within taxonomy terms -- got it.

I'll check this out.

petterw’s picture

If done correctly you should get a "Nodeorder: Order of nodes" option in your views "Sort criteria" > "add criteria" drop down.

is the views_nodeorder.inc in the modules/views/modules folder together with the other include files? (note the file should not be saved as a txt. The txt file ending is something that is added when uploaded here)

My views picked up the new up sort criteria fine. Only problem was when I made changes to the include. Had to wipe my views tables clean (as mentioned earlier) to pick up the changes. Assume some chaching going on!?

nodeorder_views_tables is a hook that interface with views.module. All correctly named files in the views/modules folder are called/included by the views.module. See the views api http://drupal.org/node/42609

I hope that was enough clues for you to get it to work.

webavant’s picture

Hope that works... I placed the file in /modules/views, not /modules/views/modules.

marcp’s picture

Folks - I have just committed a new version of nodeorder.module to CVS that incorporates the patch into nodeorder.module. I made just a couple small changes to kenandi's patch. Please test it out and set the status to "fixed" if you are satisfied. Thanks for everyone's interest in nodeorder.

-------
http://www.funnymonkey.com
Tools for Teachers

marcp’s picture

PS - I put the code in nodeorder.module per webchick's advice in this comment: http://drupal.org/node/42609#comment-146021

petterw’s picture

Unfortunately it breaks if the same node exists in two different orderable categories since it just picks out the weight_in_tid based on nid independently of tid.

After a quick look though I came across another problem with the module:
If image a,b,a are all assigned to both taxonomy-1 and taxonomy-2 only their order in taxonomy-1 is saved. Their weight_in_tid value in the db for the second entry of any of the image nodes stays 0.

Haven't had time yet to investigate it properly but does this make sense or is it just my system?

If it's a bigger problem with the node we should try and fix that first I guess, otherwise I'll give the views a bit a go within the next couple of days.

Thanks btw. marcp. for putting together the module in the first place.

marcp’s picture

See the suggestion in my comment here -- http://drupal.org/node/98584#comment-157899 -- for a quick workaround to the "node in different categories" bug. If that doesn't fix your problem, then follow it up in that issue's space. Let's keep this issue around for the Views integration.

Thanks!

Marc

gmak’s picture

Whether I add this as an include file (in modules/views/modules) or paste the code directly into nodeorder.module, I get really strange results. I'm using node order to arrange a series of images that are then called into a page via an inserted view.

1. In the sort criteria field within Views I get four items saying "nodeorder: order of nodes"
2. If I select one of the above as the sort criteria for the view, I get multiple copies of the same image being shown in the view. I can't see what logic they are being pulled in.

I've tried clearing the cache (sometimes helps to get views working properly), but nothing seems to help.

Any suggestions?

marcp’s picture

gmak - if you get the latest code, you should see "Nodorder: Order of nodes in YourVocabularyName" in the Sort Criteria. So that is a good thing.

The bad thing is that there is still a bug in the way Nodeorder interacts with Views. It really doesn't make sense to say "Order of nodes in SomeVocabulary" because the nodes may appear in multiple categories within a Vocabulary. So, really, what needs to happen is that the Sort Criteria should allow you to set the "Order of nodes in SomeTerm" where SomeTerm is any term that's in an Orderable vocabulary. That fix will require some new code.

As for now, sorting integration with Views is just plain broken...

marcp’s picture

Here is my latest attempt. I am hoping there is a way to do this without having to add code to views_taxonomy.inc.

First thing to do is to remove the views hooks in nodeorder.module (nodeorder_views_tables, nodeorder_views_arguments, and nodeorder_views_default_views). Next, you need to add the following lines to views_taxonomy.inc in your modules/views/modules directory on line 31:

    // The nodeorder module adds a column (weight_in_tid) to the core term_node table.
    // Expose it here as sortable.
    if (module_exist('nodeorder')) {
      views_table_add_sort($table, 'weight_in_tid', 'Nodeorder: Weight In Category', 'This allows you to sort by a node\'s order within it\'s category.  You should filter the search to only include a single category.');
    }

Let me know what you think....

Marc

gmak’s picture

Doing the steps suggested above (modifying the views_taxonomy.inc), I get nothing showing in my Sort Criteria that has any reference to nodeorder.

Any other possibilities?

marcp’s picture

StatusFileSize
new943 bytes

Here is a patch for views_taxonomy.inc just to make sure that the code gets in there properly. Again, if you have the latest nodeorder.module, remove the functions named nodeorder_views_tables, nodeorder_views_arguments, and nodeorder_views_default_views. I will remove those functions from the checked-in code in the next couple days.

Also, you may want to clear your cache file. You should see the following as one of the options in the Sort Criteria when creating a View:

Nodeorder: weight_in_tid

marcp’s picture

StatusFileSize
new10.17 KB

Here is a screenshot of the sort criteria option you should see... Let us know.

gmak’s picture

Still not getting anything showing up. I've cleared the cache, installed the patch, etc.

I'm using:
Views 1.159.2.18 (2006/12/03)
NodeOrder 1.5 (2006/12/01)

Is there a version problem?

marcp’s picture

Geoffrey,

Contact me via http://drupal.org/user/20885/contact and let me know how to get in touch with you. I think we'll better be able to work this out offline. I'm not sure what could be going on if you've got the Views and Nodeorder modules both enabled, removed the views_* hooks in nodeorder.module and have applied the patch attached to comment #18.

Marc

webavant’s picture

I haven't tried the most recent patch in this thread, but I've had success just sorting by nodeorder and all with a single vocabulary term. The problem I am posting about is a javascript error in IE. Works fine in FF.

Error: 'title' is undefined.

The error is in column 390 (bolded text) of this line:

Sortable.create('node-sort-list', { tag: "div", only: "sort-wrapper", handle: "title", onUpdate: function (container) { var tid = 1; var url = '/nodeorder/reordered'; new Ajax.Request(url, { method: 'post', postBody: Sortable.serialize(container.id)+'&initial-values='+initialValues+'&initial-weights='+initialWeights+'&tid='+tid } ); initialValues = Sortable.sequence(container.id); } });
<b>$(title).className</b> += ' sortable'

I haven't tried fixing it yet, but at first glance, the reason for the error has not become apparent.

webavant’s picture

My source formatting got screwed up... Apparently the comment engine does not parse tags inside of tags... Here it is without the tags:

Sortable.create('node-sort-list', { tag: "div", only: "sort-wrapper", handle: "title", onUpdate: function (container) { var tid = 1; var url = '/nodeorder/reordered'; new Ajax.Request(url, { method: 'post', postBody: Sortable.serialize(container.id)+'&initial-values='+initialValues+'&initial-weights='+initialWeights+'&tid='+tid } ); initialValues = Sortable.sequence(container.id); } });
$(title).className += ' sortable'

This code appears at column 390 on that line:
$(title).className

Anyone know why that wouldn't work in IE?

webavant’s picture

Hmm... I just remembered that this is a spajax issue, not nodeorder.

webavant’s picture

Actually there is a problem with nodeorder using the SPAJAX module. Nodeorder attempts to sort the objects contained in an object with ID "title", but that container object does not exist. Module needs to wrap the items inside a

... should fix the bug.
webavant’s picture

It appears that the container exists, but it's ID is not 'title'... it's

.
webavant’s picture

OK I was able to at least make the sorting work, although there is a new error, it does not seem to change the functionality.

In nodeorder.module change 'title' to 'node-order-list'.

    $options = array('tag' => 'div', 'only' => 'sort-wrapper', 'handle' => 'title', '#onUpdate' => $onUpdate);
webavant’s picture

hmm.... I suppose I should have created a new issue instead of all of this spam. Feel free to delete my last few posts from this thread.

pvanderspek’s picture

Version: master » 6.x-1.x-dev
Status: Needs review » Closed (fixed)

Version 5.x-1.2 has functionality to make the field accessible for the Views1 API, and version 6.x-1.x-dev integrates with the Views2 API.