Users Style in Members Profile

A perfect place for code snippets to small to be a MOD or a library.
Or for examples on how to use our libraries.
Post Reply
User avatar
RMcGirr83
Supporter
Supporter
Posts: 6242
Joined: 30 Nov 2006, 14:23
Real name: Rich McGirr

Users Style in Members Profile

Post by RMcGirr83 »

Snippet time!! :)

To get the users style to display when viewing their profile, you can add the following code. The code will obey if the board is set to override a users style and not display. So here we go.

OPEN

memberlist.php

FIND
(this find is on purpose so that you are in the correct location within memberlist.php)

Code: Select all

   case 'viewprofile':


FIND

Code: Select all

         // Get user...
         $sql = 'SELECT *
            FROM ' . USERS_TABLE . '
            WHERE ' . (($username) ? "username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'" : "user_id = $user_id");
         $result = $db->sql_query($sql);


REPLACE WITH

Code: Select all

      // get the users style
      // but only if board is set to not override
      if (!$config['override_user_style'])
      {
         // Get user and their style
         $sql = 'SELECT   u.*, s.*
            FROM ' . USERS_TABLE . ' u
            LEFT JOIN ' . STYLES_TABLE . ' s
               ON   u.user_style = s.style_id
            WHERE ' . (($username) ? "u.username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'" : "u.user_id = $user_id");            
         $result = $db->sql_query($sql);      
      }
      else
      {   
         // Get user...
         $sql = 'SELECT *
            FROM ' . USERS_TABLE . '
            WHERE ' . (($username) ? "username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'" : "user_id = $user_id");
         $result = $db->sql_query($sql);
      }


FIND

Code: Select all

         'OCCUPATION'   => (!empty($member['user_occ'])) ? censor_text($member['user_occ']) : '',


BEFORE, ADD

Code: Select all

         'USER_STYLE'   => isset($member['style_name']) ? $member['style_name'] .' '.$member['style_copyright'] : '',


OPEN

language/xxx/memberlist.php

FIND

Code: Select all

   'SORT_POST_COUNT'      => 'Post count',


AFTER, ADD

Code: Select all

   'STYLE'               => 'User Style',


OPEN

styles/prosilver/template/memberlist_view.html

FIND

Code: Select all

      <!-- IF INTERESTS --><dt>{L_INTERESTS}:</dt> <dd>{INTERESTS}</dd><!-- ENDIF -->


AFTER ADD

Code: Select all

      <!-- IF USER_STYLE --><dt>{L_STYLE}:</dt> <dd>{USER_STYLE}</dd><!-- ENDIF -->


Refresh the style and done.

You will end up with something that looks like the following.

memberlist_user_style.jpg
Post Reply