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: #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

« Next Oldest | Next Newest »

Messages In This Thread
RE: Use custom thread field in a custom page MyBB - Destro - 07-26-2013 05:23 AM

 Standard Tools
Forum Jump: