Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 HTML in $lastpost_data['lastposter']
Destroy666 Offline
Junior Member
**
Posts: 27
Joined: Jul 2012
Post: #1
HTML in $lastpost_data['lastposter']
I'm trying to add subforum info in tooltip in the forumbit_depth3 template.
This code works fine:

Code:
<li>{$statusicon} <a href="{$forum_url}" title="<if $forum_viewers_text_plain then>{$forum_viewers_text_plain}
</if>{$lang->forumbit_threads}: {$forum['threads']}
{$lang->forumbit_posts}: {$forum['posts']}<if $lastpost_data['lastposteruid'] then>
{$lang->forumbit_lastpost}: <?=htmlspecialchars_uni($lastpost_data['lastpostsubject'])?> {$lang->by} <setvar lastusername>get_user($lastpost_data['lastposteruid'])</setvar><func htmlspecialchars_uni>{$tplvars['lastusername']['username']}</func></if>">{$forum['name']}</a></li>


However, as you can see the last post username isn't made really efficient and uses unnecessary query. I had to do it like that because this code:

Code:
<li>{$statusicon} <a href="{$forum_url}" title="<if $forum_viewers_text_plain then>{$forum_viewers_text_plain}
</if>{$lang->forumbit_threads}: {$forum['threads']}
{$lang->forumbit_posts}: {$forum['posts']}<if $lastpost_data['lastposteruid'] then>
{$lang->forumbit_lastpost}: <?=htmlspecialchars_uni($lastpost_data['lastpostsubject'])?> {$lang->by} <func htmlspecialchars_uni>{$lastpost_data['lastposter']}</func></if>">{$forum['name']}</a></li>

adds usergroup HTML to name no matter if I use htmlspecialchars_uni, strip_tags or both on that variable. I'm almost sure it's caused by this (Style Usernames plugin):

PHP Code:
    public function buildForumbits(&$forum)
    {
        $this->cache['users'][$forum['lastposteruid']] = $forum['lastposter'];
        $forum['lastposter'] = "#STYLE_USERNAMES_UID{$forum['lastposteruid']}#";
    }


How would I strip HTML from the mentioned variable? Or is there any other way to get plain username using MyBB/Template Conditionals without additional query?

(This post was last modified: 09-08-2013 12:41 AM by Destroy666.)
09-07-2013 11:30 PM
Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #2
RE: HTML in $lastpost_data['lastposter']
You can try using $fcache array.

09-08-2013 03:14 AM
Find all posts by this user Quote this message in a reply
Destroy666 Offline
Junior Member
**
Posts: 27
Joined: Jul 2012
Post: #3
RE: HTML in $lastpost_data['lastposter']
Never mind, I found a plain username variable hooked in forum bits by Last/First Post Avatar plugin which I use. Thanks anyways.
(This post was last modified: 09-08-2013 08:05 AM by Destroy666.)
09-08-2013 08:05 AM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: