Thread Rating:
  • 1 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Use custom thread field in a custom page MyBB
Destro Offline
Junior Member
**
Posts: 39
Joined: Nov 2012
Post: #1
Use custom thread field in a custom page MyBB
Hi,

I want to use custom thread field in a custom page MyBB (like tos.php). How to do that?
07-24-2013 07:35 PM
Find all posts by this user Quote this message in a reply
Destro Offline
Junior Member
**
Posts: 39
Joined: Nov 2012
Post: #2
RE: Use custom thread field in a custom page MyBB
Bump. Please help.
07-26-2013 01:41 AM
Find all posts by this user Quote this message in a reply
Destro Offline
Junior Member
**
Posts: 39
Joined: Nov 2012
Post: #3
RE: Use custom thread field in a custom page MyBB
For example, I'm using this code.

PHP 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
define('IN_MYBB', 1);
define('THIS_SCRIPT', 'lctq.php');
require "./global.php";
require_once MYBB_ROOT."inc/functions_post.php";
require_once MYBB_ROOT."inc/functions_forumlist.php";
require_once MYBB_ROOT."inc/class_parser.php";
$parser = new postParser;

if ($_GET['view'] == 'phs')
{
	/* --- Initialisation. --- */
	add_breadcrumb($lang->thuquan_phs_name, "lctq.php?view=phs");
	$plugins->run_hooks("forumdisplay_start");
	$tvisibleonly = "AND t.visible='1'";
	
	/* --- Setup pagingation. --- */
	$perpage = 12;
	if(isset($mybb->input['page']) && intval($mybb->input['page']) > 0)
	{
		$page = intval($mybb->input['page']);
		$start = ($page-1) * $perpage;
		$pages = $threadcount / $perpage;
		$pages = ceil($pages);
		if($page > $pages || $page <= 0)
		{
			$start = 0;
			$page = 1;
		}
	}
	else
	{
		$start = 0;
		$page = 1;
	}

	$end = $start + $perpage;
	$lower = $start + 1;
	$upper = $end;

	if($upper > $threadcount)
	{
		$upper = $threadcount;
	}
	
	$query = $db->query("
		SELECT t.*, t.username AS threadusername, u.username
		FROM ".TABLE_PREFIX."threads t
		LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid = t.uid)
		WHERE t.fid='5' $tvisibleonly
		ORDER BY t.sticky DESC
		LIMIT $start, $perpage
	");
	
	/* --- Getting threads. --- */
	while($thread = $db->fetch_array($query))
	{		
		$threadcache[$thread['tid']] = $thread;
	}

	if(!empty($threadcache))
	{
		$count = 0;
		foreach($threadcache as $thread)
		{
			$plugins->run_hooks("forumdisplay_thread");
			$count++;

			$thread['author'] = $thread['uid'];
			if(!$thread['username'])
			{
				$thread['username'] = $thread['threadusername'];
				$thread['profilelink'] = $thread['threadusername'];
			}
			else
			{
				$thread['profilelink'] = build_profile_link($thread['username'], $thread['uid']);
			}

			$thread['subject'] = $parser->parse_badwords($thread['subject']);
			$thread['subject'] = htmlspecialchars_uni($thread['subject']);

			$prefix = '';

			$thread['threadlink'] = get_thread_link($thread['tid']);
			$thread['lastpostlink'] = get_thread_link($thread['tid'], 0, "lastpost");

			$createdate = my_date($mybb->settings['dateformat'], $thread['dateline']);
			$createtime = my_date($mybb->settings['timeformat'], $thread['dateline']);
			$lastpostdate = my_date($mybb->settings['dateformat'], $thread['lastpost']);
			$lastposttime = my_date($mybb->settings['timeformat'], $thread['lastpost']);
			$lastposter = $thread['lastposter'];
			$lastposteruid = $thread['lastposteruid'];

			// Don't link to guest's profiles (they have no profile).
			if($lastposteruid == 0)
			{
				$lastposterlink = $lastposter;
			}
			else
			{
				$lastposterlink = build_profile_link($lastposter, $lastposteruid);
			}

			$thread['replies'] = my_number_format($thread['replies']);
			$thread['views'] = my_number_format($thread['views']);
			
			if ($count == 4) {
				$count = 0;
			}
			eval("\$lcthreads .= \"".$templates->get("lctg_thuquan_phs_thread")."\";");
		}
	}
	
	eval("\$lclist = \"".$templates->get("lctg_thuquan_phs_list")."\";");
	
	/* --- Output --- */
	$plugins->run_hooks("forumdisplay_end");
	eval("\$lctq_phs = \"".$templates->get("lctg_thuquan_phs")."\";"); 
	output_page($lctq_phs);
}


But in this template lctg_thuquan_phs_thread, I can't use the threadfield variable ($GLOBAL....) What should I do ???

07-26-2013 05:23 AM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #4
RE: Use custom thread field in a custom page MyBB
You need to pull the fields data in your query.
I'm assuming you actually understand the code you posted, right?

My Blog
07-28-2013 10:41 PM
Find all posts by this user Quote this message in a reply
Destro Offline
Junior Member
**
Posts: 39
Joined: Nov 2012
Post: #5
RE: Use custom thread field in a custom page MyBB
(07-28-2013 10:41 PM)ZiNgA BuRgA Wrote:  You need to pull the fields data in your query.
I'm assuming you actually understand the code you posted, right?

Yes, I do. That's my code.
Well, I need to get the url of upload type field (it's name cover).

As normal, I just need to use this $GLOBALS['threadfields']['cover']['url'] then it will give me the url of the image. But when I check in the database (threadfields_data). The value of 'cover' field is just 0 and 1

What should I do to get that url ?
(This post was last modified: 07-29-2013 12:27 AM by Destro.)
07-29-2013 12:17 AM
Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #6
RE: Use custom thread field in a custom page MyBB
Maybe you need to look at the xtattachments table.

07-30-2013 04:11 AM
Find all posts by this user Quote this message in a reply
Destro Offline
Junior Member
**
Posts: 39
Joined: Nov 2012
Post: #7
RE: Use custom thread field in a custom page MyBB
(07-30-2013 04:11 AM)RateU Wrote:  Maybe you need to look at the xtattachments table.

How to build the Url like XThreads?

Eg:

Code:
http://example.com/xt_attach.php/2_1374420223_20e962ae/4d7e787a85a225087b594bdc27358cb5/filename.jpg

(This post was last modified: 07-30-2013 03:29 PM by Destro.)
07-30-2013 03:29 PM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #8
RE: Use custom thread field in a custom page MyBB
Use the function xthreads_get_xta_url()
Pass in the row from the xtattachments table as an array as the first argument.

If you wish to see how XThreads parses all its fields look at the xthreads_sanitize_disp and xthreads_sanitize_disp_set_xta_fields functions.

My Blog
07-31-2013 09:45 AM
Find all posts by this user Quote this message in a reply
Destro Offline
Junior Member
**
Posts: 39
Joined: Nov 2012
Post: #9
RE: Use custom thread field in a custom page MyBB
Thanks you.
07-31-2013 05:54 PM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: