Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Portal_announcement
Verilog Offline
Member
***
Posts: 50
Joined: Nov 2013
Post: #1
Portal_announcement
Hi there,
I have been doing a small experiment to show a separate latest announcement on portal where it will display announcements from XThread based forum id and display 'bonid' i.e. custom thread fields. I duplicated the code related to announcements in portal.php but my template is portal_bonlist. If I use the below variable in portal_announcement, it works but it doesn't work with portal_bonlist

Code:
{$GLOBALS['threadfields']['bonid']}


Any suggestions?
(I am okay with core edits for now)
Here is the code that I used in portal.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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
$bonlist= '';
if(!empty($mybb->settings['portal_announcementsfid']))
{

	$query = $db->simple_select("threads t", "COUNT(t.tid) AS threads", "t.visible='1' AND t.fid='10' AND t.closed NOT LIKE 'moved|%'", array('limit' => 1));
	$announcementcount = $db->fetch_field($query, "threads");

	$numannouncements = 10; // Default back to 10
	$pids = '';
	$tids = '';
	$comma = '';
	$posts = array();
	$query = $db->query("
		SELECT p.pid, p.message, p.tid, p.smilieoff
		FROM ".TABLE_PREFIX."posts p
		LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)
		WHERE t.visible='1' AND t.fid='10' AND t.closed NOT LIKE 'moved|%' AND t.firstpost=p.pid
		ORDER BY t.dateline DESC
		LIMIT 0, 10"
	);
	while($getid = $db->fetch_array($query))
	{
		$attachmentcount[$getid['tid']] = $getid['attachmentcount'];
		foreach($attachmentcount as $tid => $attach_count)
		{
			if($attach_count > 0)
			{
				$pids .= ",'{$getid['pid']}'";
			}

			$posts[$getid['tid']] = $getid;
		}

		$tids .= ",'{$getid['tid']}'";
	}
	if(!empty($posts))
	{
		if($pids != '' && $mybb->settings['enableattachments'] == 1)
		{
			$pids = "pid IN(0{$pids})";
			// Now lets fetch all of the attachments for these posts
			$query = $db->simple_select("attachments", "*", $pids);
			while($attachment = $db->fetch_array($query))
			{
				$attachcache[$attachment['pid']][$attachment['aid']] = $attachment;
			}
		}

		if(is_array($forum))
		{
			foreach($forum as $fid => $forumrow)
			{
				$forumpermissions[$fid] = forum_permissions($fid);
			}
		}

		$icon_cache = $cache->read("posticons");

		$query = $db->query("
			SELECT t.*, t.username AS threadusername, u.username, u.avatar, u.avatardimensions
			FROM ".TABLE_PREFIX."threads t
			LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid = t.uid)
		    LEFT JOIN ".TABLE_PREFIX."threadfields_data td ON (td.tid = t.tid)
			WHERE t.tid IN (0{$tids}) AND t.fid='10' AND t.visible='1' AND t.closed NOT LIKE 'moved|%'
			ORDER BY t.dateline DESC
			LIMIT 0, {$numannouncements}"
		);
		while($announcement = $db->fetch_array($query))
		{
			// Make sure we can view this announcement
			if(isset($forumpermissions[$announcement['fid']]['canonlyviewownthreads']) && $forumpermissions[$announcement['fid']]['canonlyviewownthreads'] == 1 && $announcement['uid'] != $mybb->user['uid'])
			{
				continue;
			}

			$announcement['message'] = $posts[$announcement['tid']]['message'];
			$announcement['pid'] = $posts[$announcement['tid']]['pid'];
			$announcement['smilieoff'] = $posts[$announcement['tid']]['smilieoff'];
			$announcement['threadlink'] = get_thread_link($announcement['tid']);
			$announcement['forumlink'] = get_forum_link($announcement['fid']);
			$announcement['forumname'] = $forum_cache[$announcement['fid']]['name'];
			$announcement['username'] = htmlspecialchars_uni($announcement['username']);
			if(!$announcement['uid'] && !$announcement['threadusername'])
			{
				$announcement['threadusername'] = htmlspecialchars_uni($lang->guest);
			}
			else
			{
				$announcement['threadusername'] = htmlspecialchars_uni($announcement['threadusername']);
			}

			if($announcement['uid'] == 0)
			{
				$profilelink = $announcement['threadusername'];
			}
			else
			{
				$profilelink = build_profile_link($announcement['username'], $announcement['uid']);
			}

			if(!$announcement['username'])
			{
				$announcement['username'] = $announcement['threadusername'];
			}
			$announcement['subject'] = htmlspecialchars_uni($parser->parse_badwords($announcement['subject']));

			$useravatar = format_avatar($announcement['avatar'], $announcement['avatardimensions']);
			eval("\$avatar = \"".$templates->get("portal_announcement_avatar")."\";");

			$anndate = my_date('relative', $announcement['dateline']);

			if($announcement['replies'])
			{
				eval("\$numcomments = \"".$templates->get("portal_announcement_numcomments")."\";");
			}
			else
			{
				eval("\$numcomments = \"".$templates->get("portal_announcement_numcomments_no")."\";");
				$lastcomment = '';
			}

			$senditem = '';
			if($mybb->user['uid'] > 0 && $mybb->usergroup['cansendemail'] == 1)
			{
				eval("\$senditem = \"".$templates->get("portal_announcement_send_item")."\";");
			}

			$plugins->run_hooks("portal_announcement");

			$parser_options = array(
				"allow_html" => $mybb->settings['announcementshtml'] && $forum[$announcement['fid']]['allowhtml'],
				"allow_mycode" => $forum[$announcement['fid']]['allowmycode'],
				"allow_smilies" => $forum[$announcement['fid']]['allowsmilies'],
				"allow_imgcode" => $forum[$announcement['fid']]['allowimgcode'],
				"allow_videocode" => $forum[$announcement['fid']]['allowvideocode'],
				"filter_badwords" => 1
			);
			if($announcement['smilieoff'] == 1)
			{
				$parser_options['allow_smilies'] = 0;
			}

			if($mybb->user['showimages'] != 1 && $mybb->user['uid'] != 0 || $mybb->settings['guestimages'] != 1 && $mybb->user['uid'] == 0)
			{
				$parser_options['allow_imgcode'] = 0;
			}

			if($mybb->user['showvideos'] != 1 && $mybb->user['uid'] != 0 || $mybb->settings['guestvideos'] != 1 && $mybb->user['uid'] == 0)
			{
				$parser_options['allow_videocode'] = 0;
			}

			$message = $parser->parse_message($announcement['message'], $parser_options);


			eval("\$bonlists.= \"".$templates->get("portal_bonlist")."\";");
			unset($post);
		}
	}
}

06-02-2020 04:42 PM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

Messages In This Thread
Portal_announcement - Verilog - 06-02-2020 04:42 PM
RE: Portal_announcement - RateU - 06-03-2020, 03:38 AM
RE: Portal_announcement - Verilog - 06-03-2020, 04:17 PM
RE: Portal_announcement - Verilog - 06-07-2020, 02:07 AM
RE: Portal_announcement - RateU - 06-07-2020, 03:46 AM
RE: Portal_announcement - Verilog - 06-07-2020, 04:51 PM
RE: Portal_announcement - RateU - 06-08-2020, 02:58 AM
RE: Portal_announcement - Verilog - 06-08-2020, 07:23 PM
RE: Portal_announcement - RateU - 06-09-2020, 01:41 AM
RE: Portal_announcement - Verilog - 06-09-2020, 06:01 PM

 Standard Tools
Forum Jump: