Portal subject - max characters
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #1
Portal subject - max characters
I have been trying to set the maximum displayed characters in a portal announcement subject using the my_strlen function from mybb. Here is my code:

PHP Code:
	if(my_strlen($announcement['subject']) > 25)
		{
			$announcement['subject'] = my_substr($announcement['subject'], 0, 25) . "...";
		}
	$announcement['subject'] = htmlspecialchars_uni($parser->parse_badwords($announcement['subject']));


I just added it into the portal php like so:

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
$announcements = '';
$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 ".(($page-1)*$perpage).", ".$perpage
);
while($announcement = $db->fetch_array($query))
{

	$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']);
	
	if($announcement['uid'] == 0)
	{
		$profilelink = htmlspecialchars_uni($announcement['threadusername']);
	}
	else
	{
		$profilelink = build_profile_link($announcement['username'], $announcement['uid']);
	}
	
	if(!$announcement['username'])
	{
		$announcement['username'] = $announcement['threadusername'];
	}
	if(my_strlen($announcement['subject']) > 25)
		{
			$announcement['subject'] = my_substr($announcement['subject'], 0, 25) . "...";
		}
	$announcement['subject'] = htmlspecialchars_uni($parser->parse_badwords($announcement['subject']));
	if($announcement['icon'] > 0 && $icon_cache[$announcement['icon']])
	{
		$icon = $icon_cache[$announcement['icon']];
		$icon = "<img src=\"{$icon['path']}\" alt=\"{$icon['name']}\" />";
	}
	else
	{
		$icon = "&nbsp;";
	}

etc etc, rest of portal.php as standard.


It's having no result and I don't quite see why. Can anyone advise where I am going wrong?



[Image: leelink.gif]
MYBB1.6 & XThreads
07-16-2011 08:58 PM
Visit this user's website Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

Messages In This Thread
Portal subject - max characters - leefish - 07-16-2011 08:58 PM

 Standard Tools
Forum Jump: