threadlist last poster name length?
#1
By default what is the length of the username in threadlist last post column before it gets cut ...

What file controls that function????

Looks like I found it:

forumdisplay.php
$lastposterlink = build_profile_link($lastposter, $lastposteruid);

Is there a way to do it without modifying core file????
Reply
#2
You'll need to have a plugin do this. Try hooking to forumdisplay_thread. Globalize the variables $mybb and $thread.
Reply
#3
Ok this is embarrassing all my threads sooner or later end up talking about plugins.
Moderators please move this thread was not really trying to discuss plugin here!

<hr>
I am using this but doesn't seem to do anything!

Important!!!!!!! My initial intention was not to talk about plugin here!!!!!!

$plugins->add_hook("forumdisplay_thread", "threadlist_username_cut");
function threadlist_username_cut()
{
    global $mybb, $thread;

	if(strlen($thread['lastposter']) > "5")
		{
			$lastposter = htmlspecialchars_uni(my_substr($lastposter,0,5)."...");
		}
}
Reply
#4
You can't modify the lastposter variable because it's defined after hook.

But you can define a new variable:
function threadlist_username_cut()
{
    global $thread, $newlastposterlink;

    if(strlen($thread['lastposter']) > 5)
        {
            $newlastposter = htmlspecialchars_uni(my_substr($thread['lastposter'], 0, 5)).'...';
            $newlastposterlink = $thread['lastposteruid'] ? build_profile_link($newlastposter, $thread['lastposteruid']) : $newlastposter;
        }
}
And then add that variable to template instead of the old link.
Reply
#5
@Destroy666 buddy thanks very much lets don't forget @dragonexpert too!

Guys thanks very much. From now on I just gonna post in plugins support cause no matter what I do I end up talking about codes and plugins and this got me into trouble already once don't really want to receive a warning Smile
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)