Help - Search - Members - Calendar
Full Version: [IPB]user group list format
Neowin Forums > Help & Discussion Center > Web Server Side > Bulletin Board Support
OMEGA_RAZER
Is there any way to, like here at Neowin, have the online list format (the span colors) show in topics for usernames? I'm using v2.3.3 if that makes a difference.
Jack 0Neill
I've seen mods for this on externals sites, bit it raises the queries by about 20+.

I too am interested in this.
OMEGA_RAZER
Do you remember where you saw them? I'm just testing stuff out now so I don't have to worry about high traffic/queries...
Jack 0Neill
Unfortunately I do not recall where. But I do remember it was well over a year ago and I believe it was for 2.1.x
Dragyn
Assuming what you want is to have the group color be the name color in topics..
Here's 1 way of doing it.

sources/sql/mysql_queries.php

function topics_get_posts_with_join( $a )

Add with the other left joins:

CODE
LEFT JOIN ".SQL_PREFIX."groups g ON (m.mgroup=g.g_id)


then add this into the select line: g.prefix, g.suffix,

like this (may vary depending what you have done)
make sure the other lines are still there (m.id, m.name, m.mgroup) etc etc.
CODE
return "SELECT p.*, pp.*, g.prefix, g.suffix,



then sources/action_public/topics.php

find:
CODE
$poster['_members_display_name'] = "<a href='{$this->base_url}showuser={$poster['id']}'>{$poster['members_display_name_short']}</a>";


change to:

CODE
$poster['_members_display_name'] = "<a href='{$this->base_url}showuser={$poster['id']}'>{$poster['prefix']}{$poster['members_display_name_short']}{$poster['suffix']}</a>";


This should do it. Unless I forgot something.
OMEGA_RAZER
Thanks, will try this tomorrow and let you know how it works.
OMEGA_RAZER
just tried this and it worked perfectly, thanks a lot biggrin.gif
Swiftie
Got this working superbly in the topics..

Any way of implementing it to work on the topics list aswell?

Many thanks
Dragyn
I haven't tested this that much so use at your own risk.
This will change the 'Topic Starter' into the group prefix/suffix format.
Probably others ways of doing it but this is what I have so far.


sql/mysql_queries.php

we're adding: ,m.mgroup and LEFT JOIN ".SQL_PREFIX."members m ON (t.starter_id=m.id)
make it look like this
this will do the 'I replied' topic listings

CODE
function forums_get_replied_topics_actual( $a )
    {
        return  "SELECT DISTINCT(p.author_id), t.* ,m.mgroup
                    FROM ".SQL_PREFIX."topics t
                          LEFT JOIN ".SQL_PREFIX."posts p ON (p.topic_id=t.tid AND p.author_id={$a['mid']})
                        LEFT JOIN ".SQL_PREFIX."members m ON (t.starter_id=m.id)
                     WHERE t.forum_id={$a['fid']} AND {$a['query']} AND p.new_topic=0
                     ORDER BY t.pinned desc,{$a['topic_sort']} {$a['sort_key']} {$a['r_sort_by']}
                     LIMIT {$a['limit_a']}, {$a['limit_b']}";
    }


action_public/forums.php

find:
CODE
// No point in getting dots again...

a little bit under that you will see this.

CODE
else
        {
            $this->ipsclass->DB->simple_construct( array( 'select' => '*',
                                                          'from'   => 'topics t',
                                                          'where'  =>  $query . $add_query,
                                                          'order'  => 't.pinned DESC, '.$topic_sort.' t.'.$sort_key .' '. $r_sort_by,
                                                          'limit'  => array( intval($First), $this->ipsclass->vars['display_max_topics'] )
                                                 )      );
            $this->ipsclass->DB->simple_exec();
        }


change to:

CODE
else
        {
            $this->ipsclass->DB->simple_construct( array( 'select' => 't.*',
                                                          'from'   => array('topics' => 't'),
                                                          'where'  =>  $query . $add_query,
                                                          'order'  => 't.pinned DESC, '.$topic_sort.' t.'.$sort_key .' '. $r_sort_by,
                                                          'limit'  => array( intval($First), $this->ipsclass->vars['display_max_topics'] ),
                                                        'add_join' => array( 0 => array( 'select' => 'm.mgroup', 'from' => array( 'members' => 'm'), 'where' => 't.starter_id=m.id',   'type'   => 'left'  ) )
                                                 )      );
            $this->ipsclass->DB->simple_exec();
        }


then find

CODE
        $topic['starter']     = $topic['starter_id']     ? $this->ipsclass->make_profile_link( $topic['starter_name'], $topic['starter_id']) : $this->ipsclass->vars['guest_name_pre'] . $topic['starter_name'] . $this->ipsclass->vars['guest_name_suf'];


change to

CODE
        $topic['starter']     = $topic['starter_id']     ? $this->ipsclass->make_profile_link( $this->ipsclass->make_name_formatted($topic['starter_name'],$topic['mgroup']), $topic['starter_id']) : $this->ipsclass->vars['guest_name_pre'] . $topic['starter_name'] . $this->ipsclass->vars['guest_name_suf'];


that should do it. any problems, let me know.
this is just getting the mgroup from the members table and then making the names formatted in the listings.
Couch Potato
Any way to integrate this in the "Last replied" section as well? ( On the forum index and on the topic list view )
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.