Forum Name In Portal Announcement
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #1
Forum Name In Portal Announcement
Useless maybe. But I just want to share this. I hope it is OK Biggrin

This is a very simple plugin for displaying forum name and forum link for each announcements in portal announcements.

Put {$mnann_forum_name} variable in portal_announcement template.

   


Attached File(s)
.php  mnann_forum_name.php (Size: 951 bytes / Downloads: 421)

02-19-2011 05:10 AM
Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #2
RE: Forum Name In Portal Announcement
Yea, I like this - I have something similar, but not coolly IN the announcement text.


[Image: leelink.gif]
MYBB1.6 & XThreads
02-21-2011 10:05 AM
Visit this user's website Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #3
RE: Forum Name In Portal Announcement
We can place the variable anywhere in that template. It is for example only Biggrin

If we are a fans of PHP In Template or Template Conditional plugins (and I'm a fans of PHP In Template plugin Biggrin), we don't need it. We can use those plugins for this. And if we use XThreads, it is more easier for us, because we can use (I think) {$forumurl} variable as forum link.

(This post was last modified: 02-22-2011 03:18 AM by RateU.)
02-22-2011 03:17 AM
Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #4
RE: Forum Name In Portal Announcement
Yea, this is the code I use in my prefix_portal_announcement

HTML 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
<table cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
	<tr>
		<td class="thead" colspan="{$colspan}">
			<div style="float: right;">
				<span><strong><a href="{$mybb->settings['bburl']}/forum-{$announcement['fid']}.html">{$announcement['forumname']}</a></strong></span>
			</div>
			<div style="float: left;">{$icon}</div><div><strong><a href="{$mybb->settings['bburl']}/showthread.php?tid={$announcement['tid']}">{$announcement['subject']}</a></strong>				
		</div>
		</td>
	</tr>

<tr>
<td class="trow1" align="right">
<span class="smalltext">{$lang->posted_by} <a href="{$mybb->settings['bburl']}/member.php?action=profile&amp;uid={$announcement['uid']}">{$announcement['username']}</a>  - {$anndate} {$anntime} {$numcomments}</span>
</td>
</tr>
<tr>
<td class="fancy" colspan="5"><span class="smalltext"></span></td>
</tr>
<tr>
<td class="trow1">
<table border="0" cellpadding="{$theme['tablespace']}" width="100%">
<tr>
<td>
<div class="trow1"><img src="{$GLOBALS['threadfields']['book_jacket']['url']}/thumb320x240" alt="gahhhh" /></div>
</td>
<td>
<div class="trow1">{$message}</div><br />
<div class="trow1" ><a href="{$mybb->settings['bburl']}/showthread.php?tid={$announcement['tid']}"><span class="smalltext"><em>Read More</em></span></a></div><br />
</td>
</tr>
</table>
</td>
</tr>
</table>
<br />


Its just a template edit. Maybe its inefficient like this?



[Image: leelink.gif]
MYBB1.6 & XThreads
02-22-2011 09:30 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Imran Offline
Member
***
Posts: 204
Joined: Apr 2010
Post: #5
RE: Forum Name In Portal Announcement
Nice idea RateU Smile

[Image: logo.png]

[Image: twitter.png]
02-22-2011 07:28 PM
Visit this user's website Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #6
RE: Forum Name In Portal Announcement
@ Leefish: I don't know what do you mean by "inefficient", Lee. Do you use a plugin for this? Because I can't find the {$announcement['forumname']} as a default variable in portal announcement.....

02-23-2011 01:24 AM
Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #7
RE: Forum Name In Portal Announcement
Oh yes. I forgot - I also edited my portal.php for the latest threads box. I added a couple of variables into the announcements bit....That way you can jump through to the forum from the latest threads box. Re inefficient - I mean changing templates and whatnot rather than a neat plugin. Especially if its using Zinga Burga's control object.

Here is the code from my portal.php, but I don't think this was the cause...... (made it a while ago)

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
// Latest forum discussions
if($mybb->settings['portal_showdiscussions'] != 0 && $mybb->settings['portal_showdiscussionsnum'])
{
	$altbg = alt_trow();
	$threadlist = '';
	$uv = str_replace('fid', 't.fid', $unviewwhere);
	$query = $db->query("
		SELECT t.*, u.username, f.name AS forumname
		FROM ".TABLE_PREFIX."threads t
		LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=t.uid)
		LEFT JOIN ".TABLE_PREFIX."forums f ON (f.fid=t.fid)
		WHERE 1=1 $uv AND t.visible='1' AND t.closed NOT LIKE 'moved|%'
		AND t.fid NOT IN(15,20,43,44,68,45)
		ORDER BY t.lastpost DESC 
		LIMIT 0, ".$mybb->settings['portal_showdiscussionsnum']
	);
	while($thread = $db->fetch_array($query))
	{
		$lastpostdate = my_date($mybb->settings['dateformat'], $thread['lastpost']);
		$lastposttime = my_date($mybb->settings['timeformat'], $thread['lastpost']);
		// Don't link to guest's profiles (they have no profile).
		if($thread['lastposteruid'] == 0)
		{
			$lastposterlink = $thread['lastposter'];
		}
		else
		{
			$lastposterlink = build_profile_link($thread['lastposter'], $thread['lastposteruid']);
		}
		if(my_strlen($thread['subject']) > 25)
		{
			$thread['subject'] = my_substr($thread['subject'], 0, 25) . "...";
		}
$thread['subject'] = htmlspecialchars_uni($parser->parse_badwords($thread['subject']));
$thread['threadlink'] = get_thread_link($thread['tid']);
$thread['lastpostlink'] = get_thread_link($thread['tid'], 0, "lastpost");
eval("\$threadlist .= \"".$templates->get("portal_latestthreads_thread")."\";");
$altbg = alt_trow();
	}
	if($threadlist)
	{ 
		// Show the table only if there are threads
		eval("\$latestthreads = \"".$templates->get("portal_latestthreads")."\";");
	}
}

// Get latest news announcements
// First validate announcement fids:
$announcementsfids = explode(',', $mybb->settings['portal_announcementsfid']);
if(is_array($announcementsfids))
{
	foreach($announcementsfids as $fid)
	{
		$fid_array[] = intval($fid);
	}
	$announcementsfids = implode(',', $fid_array);
}
// And get them!
$query = $db->simple_select("forums", "*", "fid IN (".$announcementsfids.")");
while($forumrow = $db->fetch_array($query))
{
    $forum[$forumrow['fid']] = $forumrow;
}

$pids = '';
$tids = '';
$comma = '';
$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.fid IN (".$announcementsfids.") AND t.visible='1' AND t.closed NOT LIKE 'moved|%' AND t.firstpost=p.pid
	ORDER BY t.dateline DESC 
	LIMIT 0, ".$mybb->settings['portal_numannouncements']
);
while($getid = $db->fetch_array($query))
{
	$pids .= ",'{$getid['pid']}'";
	$tids .= ",'{$getid['tid']}'";
	$posts[$getid['tid']] = $getid;
}
$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");



[Image: leelink.gif]
MYBB1.6 & XThreads
02-23-2011 07:52 AM
Visit this user's website Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #8
RE: Forum Name In Portal Announcement
Assuming you did the same modification in your announcement query (joining the forum table to get the forum name), and add $announcement['forumname'] to the portal.php, as I said in the previous post, I think we can do that with Template Conditional or PHP In Template only (to get the "proper" forum link and do some "HTML validating" for forum name, if we care about validating our page). If all forums use usual forum name (without HTML entities), it only used for getting the proper forum link. And, if we use XThreads, we can use {$forumurl} variable as forum URL (provided by XThreads in portal announcement).
So, in Portal Announcement, I think we don't need to edit our portal.php file if we only want the forum name and forum link/URL.

Sorry if my opinion above is wrong Biggrin

02-24-2011 04:51 AM
Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #9
RE: Forum Name In Portal Announcement
Yea, so thats what I meant about it being "less efficient" - I was posting all that code to show you that your way was better Smile


[Image: leelink.gif]
MYBB1.6 & XThreads
02-24-2011 05:59 AM
Visit this user's website Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #10
RE: Forum Name In Portal Announcement
For latest thread/discussion block in portal, I think it is a bit similar if we want only to get the forum name and forum URL. We need Template Conditional or PHP In Template plugin for that to get the proper forum link and forum name. I think (again), we can use forum cache for getting the forum name.

But which is better, using code edit or using Template Conditional, the best person can answer this question is Yumi Biggrin

02-24-2011 09:18 AM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: