Thread Rating:
  • 1 Votes - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 How to display forum names on portal page
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #1
How to display forum names on portal page
I personally find it a nice thing to have (I have this at Endless Paradigm)

To add the forum name, for each portal announcement, just perform the following code edits.

Open up portal.php.
Find:

PHP Code:
1
2
3
4
5
6
7
8
$query = $db->query("
	SELECT t.*, t.username AS threadusername, u.username, u.avatar
	FROM ".TABLE_PREFIX."threads t
	LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid = t.uid)
	WHERE fid IN (".$mybb->settings['portal_announcementsfid'].") AND t.visible='1' AND t.closed NOT LIKE 'moved|%'
	ORDER BY t.dateline DESC
	LIMIT 0, ".$mybb->settings['portal_numannouncements']
);


Replace with:

PHP Code:
1
2
3
4
5
6
7
8
9
$query = $db->query("
	SELECT t.*, t.username AS threadusername, u.username, u.avatar, 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 t.fid IN (".$mybb->settings['portal_announcementsfid'].") AND t.visible='1' AND t.closed NOT LIKE 'moved|%'
	ORDER BY t.dateline DESC
	LIMIT 0, ".$mybb->settings['portal_numannouncements']
);


Next, open up your portal_announcement template, and place {$announcement['forumname']} wherever you want it to appear.  You can use {$announcement['fid']} if you need to grab the FID of the forum.

That's it!


My Blog
01-27-2008 01:18 AM
Find all posts by this user
Constrictor Offline
Junior Member
**
Posts: 16
Joined: Jan 2008
Post: #2
RE: How to display forum names on portal page
Thx for sharing !
01-27-2008 03:20 AM
Find all posts by this user
mcman2008 Offline
Junior Member
**
Posts: 2
Joined: Jan 2008
Post: #3
RE: How to display forum names on portal page
Thank you but if I want to show it in front of each thread subject in "Lastest Threads" section not in announcement section.

ex.
[Tutorials, Guides, Mods & Resources] How to display forum names on portal page
[Releases] AJAX Quick Reply 1.2

How to midify code?
Thank you again
01-27-2008 06:53 PM
Find all posts by this user
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #4
RE: How to display forum names on portal page
Oh okay, sorry.

In portal.php
Find:

PHP Code:
1
2
3
4
5
6
7
8
	$query = $db->query("
		SELECT t.*, u.username
		FROM ".TABLE_PREFIX."threads t
		LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=t.uid)
		WHERE 1=1 $unviewwhere AND t.visible='1' AND t.closed NOT LIKE 'moved|%'
		ORDER BY t.lastpost DESC 
		LIMIT 0, ".$mybb->settings['portal_showdiscussionsnum']
	);

Replace with:

PHP Code:
1
2
3
4
5
6
7
8
9
10
	$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|%'
		ORDER BY t.lastpost DESC 
		LIMIT 0, ".$mybb->settings['portal_showdiscussionsnum']
	);

Then edit your portal_latestthreads_thread template - add {$thread['forumname']} wherever you want the name to appear.  You can also use {$thread['fid']} if you need the FID.


My Blog
01-27-2008 07:07 PM
Find all posts by this user
MyBB Us3r Offline
Junior Member
**
Posts: 19
Joined: Jan 2008
Post: #5
RE: How to display forum names on portal page
Nice.

I've been looking for something like this, and it comes in handy if you're pulling posts from multiple sections as users know where it's coming from.
(This post was last modified: 01-28-2008 06:45 AM by MyBB Us3r.)
01-28-2008 06:45 AM
Find all posts by this user
pepotiger Offline
Junior Member
**
Posts: 18
Joined: Jan 2008
Post: #6
RE: How to display forum names on portal page
as useal u read my mind Tongue
I was looking for it too, thanks mate for sharing it..
ُEdit: the {$announcement['forumname']} not working, I tryed to add

PHP Code:
<a href="{$mybb->settings['bburl']}/forum-{$announcement['fid']}.html">{$announcement['forumname']}</a>

the forum fid working good whene I view the page source, but there is no input replaced with {$announcement['forumname']}

Note: I applyed the changes in this topic http://mybbhacks.zingaburga.com/showthread.php?tid=54

(This post was last modified: 01-28-2008 10:33 AM by pepotiger.)
01-28-2008 09:36 AM
Find all posts by this user
mcman2008 Offline
Junior Member
**
Posts: 2
Joined: Jan 2008
Post: #7
RE: How to display forum names on portal page
Thank you very much. It's work! Tongue
01-28-2008 10:20 AM
Find all posts by this user
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #8
RE: How to display forum names on portal page
pepotiger Wrote:as useal u read my mind Tongue
I was looking for it too, thanks mate for sharing it..
ُEdit: the {$announcement['forumname']} not working, I tryed to add

PHP Code:
<a href="{$mybb->settings['bburl']}/forum-{$announcement['fid']}.html">{$announcement['forumname']}</a>

the forum fid working good whene I view the page source, but there is no input replaced with {$announcement['forumname']}

Note: I applyed the changes in this topic http://mybbhacks.zingaburga.com/showthread.php?tid=54

Oh yes, there will be a conflict if you copy the code exactly...
If you're using pagination on portal as well, instead of using the replacement in the first post, use this replacement:

PHP Code:
1
2
3
4
5
6
7
8
9
$query = $db->query("
	SELECT t.*, t.username AS threadusername, u.username, u.avatar, 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 t.fid IN (".$mybb->settings['portal_announcementsfid'].") AND t.visible='1' AND t.closed NOT LIKE 'moved|%'
	ORDER BY t.dateline DESC
	LIMIT ".(($page-1)*$perpage).", ".$perpage
);


My Blog
01-28-2008 06:40 PM
Find all posts by this user
pepotiger Offline
Junior Member
**
Posts: 18
Joined: Jan 2008
Post: #9
RE: How to display forum names on portal page
working very well now.. thanks mate Smile
01-28-2008 09:55 PM
Find all posts by this user
Teduhdulu Offline
Junior Member
**
Posts: 10
Joined: Feb 2008
Post: #10
RE: How to display forum names on portal page
work for me also  Smile
06-13-2008 09:44 PM
Find all posts by this user

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: