last day (14 days later) » 

8:09 AM
:) welcome
 
TBJ
thanks!
So this is the string of nids given by my contextual filter:
20697,20735,20768,20903,20695,21863,20743,20726,20710,20730,20719,20691,20693,20701,20713,20699,20724,20751,20758,20859,20860,20861,20857,20858
24 of them actually...
 
And without sorting they are in the view
view output
 
TBJ
yes, but not in the order given
so I first tried with a sorting critera
And when that tid not work I tried with hook_views_pre_render
 
so you can confirm that all of these nids are in the pre-render's $view->result as well.
 
TBJ
But you are probably right... if I remember correctly there are 22 nids in view->result
 
8:13 AM
As long as they all belong to the list.
you use dmp or debugger
 
TBJ
Problaby because there are 2 or 3 unpublished nids
devel
 
and what is the dmp output of $sortorder just before you call usort
 
TBJ
Wait 1 minute while i write that line
... (Array, 24 elements)

0 (String, 5 characters ) 20697
1 (String, 5 characters ) 20735
2 (String, 5 characters ) 20768
3 (String, 5 characters ) 20903
4 (String, 5 characters ) 20695
5 (String, 5 characters ) 21863
6 (String, 5 characters ) 20743
7 (String, 5 characters ) 20726
8 (String, 5 characters ) 20710
9 (String, 5 characters ) 20730
10 (String, 5 characters ) 20719
11 (String, 5 characters ) 20691
12 (String, 5 characters ) 20693
13 (String, 5 characters ) 20701
14 (String, 5 characters ) 20713
So $sortorder is identical with the string given from the contextual filter
 
So that corresponds to the nids passed into the contextual filter.
 
TBJ
yes, I was surprised first that there was a need for a sorting function at all, I thought that the nodes would appear in the given order
 
8:19 AM
Can you output a list of the nids contained in $view->result just before calling usort. Reason is that if it is not in the list it will return FALSE from array_search, and if two of then are bieng compared FALSE === FLASE
 
TBJ
ok
 
nodes by default appaear in nid order
 
TBJ
aha
Had to do a couple of lines with a foreach to accomplis the list of nids:

... (Array, 22 elements)

0 (String, 5 characters ) 20691
1 (String, 5 characters ) 20693
2 (String, 5 characters ) 20695
3 (String, 5 characters ) 20697
4 (String, 5 characters ) 20699
5 (String, 5 characters ) 20701
6 (String, 5 characters ) 20710
7 (String, 5 characters ) 20713
8 (String, 5 characters ) 20719
9 (String, 5 characters ) 20724
10 (String, 5 characters ) 20726
11 (String, 5 characters ) 20730
12 (String, 5 characters ) 20743
 
also FALSE will evaluate to 0, so if nid is not present it will be sorted before any other nodes
 
TBJ
this is the list of nids contained in $vire->result before calling usort
 
8:25 AM
And what is $view->result nids after usort?
 
TBJ
This the same array after calling usort

... (Array, 22 elements)

0 (String, 5 characters ) 20697
1 (String, 5 characters ) 20768
2 (String, 5 characters ) 20695
3 (String, 5 characters ) 21863
4 (String, 5 characters ) 20743
5 (String, 5 characters ) 20726
6 (String, 5 characters ) 20710
7 (String, 5 characters ) 20730
8 (String, 5 characters ) 20719
9 (String, 5 characters ) 20691
10 (String, 5 characters ) 20693
11 (String, 5 characters ) 20701
12 (String, 5 characters ) 20713
13 (String, 5 characters ) 20699
 
So the usort does work properly
 
TBJ
Uh?
 
The View->result after usort is sorted in the order you want
 
TBJ
The four first in $sortorder:
20697,20735,20768,20903
The four first after sorting:
0 (String, 5 characters ) 20697
1 (String, 5 characters ) 20768
2 (String, 5 characters ) 20695
3 (String, 5 characters ) 21863
 
8:31 AM
20735 and 20903 is not in the list of nodes
unpublished
 
TBJ
Hmmm
 
Not in the list of $view->result before usort
 
TBJ
Aha...
 
Is it rendering in correct order
 
TBJ
OK, many many thanks! That one needed an extra pair of eyes. You save my weekend actually :-)
How can i return the favor?
 
8:39 AM
Not ow worry. Enjoy the weekend. Cheers
 
TBJ
Cheers! And thanks again
 

last day (14 days later) »