Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 [Solved] Display/Sort forum threadlist with xthread field ?
akm Offline
Member
***
Posts: 115
Joined: Nov 2011
Post: #21
RE: Display/Sort forum threadlist with xthread field ?
(03-14-2012 07:21 AM)ZiNgA BuRgA Wrote:  You can check MyBB's debug page ("advanced details" link at bottom of each page) and see if the query is sorting by the thread field.

Interesting, thank you for the direction !
Am not sure how to interpret the debug info.
Have attached a PDF copy.

In the sample case in this thread, the sorting threadfield key was ct_ .
In this real case (the PDF) it is cl_ , along with several other customfields... sl_, hrn_, hrp_, bp_, bpg_, and tow_  (not used in sorting).
The templateprefix is cr_.

The sorting is setup (theoretically) to be done with either the 'subject' or 'cl_' .
The test of 'subject' sorting is working, but the cl_ is not... actually it acts like it is being sorted by post date.

Hopefully you have a chance to take a look at the PDF and pass on some clue/s.
Can see Sort Queries with (among other things) threadfield 'keys' and with 'lastpost' (default shown at forumdisplay.php, whatever that means)...

Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Sort by which field?
if(!isset($mybb->input['sortby']) && !empty($foruminfo['defaultsortby']))
{
	$mybb->input['sortby'] = $foruminfo['defaultsortby'];
}

$t = "t.";

$sortby = htmlspecialchars($mybb->input['sortby']);
switch($mybb->input['sortby'])
{
	case "subject":
		$sortfield = "subject";
		break;
	case "replies":
		$sortfield = "replies";
		break;
	case "views":
		$sortfield = "views";
		break;
	case "starter":
		$sortfield = "username";
		break;
	case "rating":
		$t = "";
		$sortfield = "averagerating";
		$sortfield2 = ", t.totalratings DESC";
		break;
	case "started":
		$sortfield = "dateline";
		break;
	default:
		$sortby = "lastpost";
		$sortfield = "lastpost";
		$mybb->input['sortby'] = "lastpost";
		break;
}



Attached File(s)
.pdf  MyBB Debug Information-120313.pdf (Size: 33.79 KB / Downloads: 532)

Thanks again for your help !
03-14-2012 10:01 AM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #22
RE: Display/Sort forum threadlist with xthread field ?
Yes, it is by lastpost as you can see from the query (note the ORDER BY clause):

SQL Code
1
2
3
4
5
6
7
SELECT t.*, tfd.`cl_` AS `xthreads_cl_`, tfd.`sl_` AS `xthreads_sl_`, tfd.`hrn_` AS `xthreads_hrn_`, tfd.`hrp_` AS
`xthreads_hrp_`, tfd.`bp_` AS `xthreads_bp_`, tfd.`bpj_` AS `xthreads_bpj_`, tfd.`tow_` AS `xthreads_tow_`, t.username AS
threadusername, u.username
FROM mybb_threads t LEFT JOIN mybb_users u ON (u.uid = t.uid) LEFT JOIN `mybb_threadfields_data` tfd ON t.tid=tfd.tid
WHERE t.fid='24' AND (t.visible='1' OR t.visible='0')
ORDER BY t.sticky DESC, t.lastpost desc
LIMIT 0, 20


If it's "cl_", then you need to use that as the key, ie sort by "tf_cl_"


My Blog
(This post was last modified: 03-14-2012 10:27 AM by ZiNgA BuRgA.)
03-14-2012 10:26 AM
Find all posts by this user Quote this message in a reply
akm Offline
Member
***
Posts: 115
Joined: Nov 2011
Post: #23
RE: Display/Sort forum threadlist with xthread field ?
(03-14-2012 10:26 AM)ZiNgA BuRgA Wrote:  Yes, it is by lastpost as you can see from the query (note the ORDER BY clause):

SQL Code
1
2
3
4
5
6
7
SELECT t.*, tfd.`cl_` AS `xthreads_cl_`, tfd.`sl_` AS `xthreads_sl_`, tfd.`hrn_` AS `xthreads_hrn_`, tfd.`hrp_` AS
`xthreads_hrp_`, tfd.`bp_` AS `xthreads_bp_`, tfd.`bpj_` AS `xthreads_bpj_`, tfd.`tow_` AS `xthreads_tow_`, t.username AS
threadusername, u.username
FROM mybb_threads t LEFT JOIN mybb_users u ON (u.uid = t.uid) LEFT JOIN `mybb_threadfields_data` tfd ON t.tid=tfd.tid
WHERE t.fid='24' AND (t.visible='1' OR t.visible='0')
ORDER BY t.sticky DESC, t.lastpost desc
LIMIT 0, 20

If it's "cl_", then you need to use that as the key, ie sort by "tf_cl_"


Well, that seems to have done it, sorts correctly, and shows on the debug info accordingly, thanks much !

Guess just got confused with terminology 'names' and 'keys' in the undoc.

Seems almost like tf_ could be called a threadfilter 'prefix' or 'key' with cl_ the threadfield 'key', and the word 'name' just confuses the question... then tf_ used kinda like a template prefix with threadfield keys, ie tf_cl_

But then thats just me (an my beginner logic), am sure others understand better the way it is.

But for now, seems like the question is answered !

Thanks again for your help !
03-14-2012 02:46 PM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #24
RE: Display/Sort forum threadlist with xthread field ?
Yeah, it basically is a prefix.  It's needed to force uniqueness in names.

My Blog
03-14-2012 03:58 PM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: