Main Menu
collapse

Simple Portal Archived Forum

This is an Archive Forum.

The content in this forum may be out-of-date or have been superseded by newer information, and links in forum pages to other sites may not work.
This forum contains archives for future reference.

Visit our thread at Simple Machines Forum for current support.

SMF 2.1 users: EhPortal is a ported version of Simple Portal specifically designed for the SMF 2.1 branch.
Please visit web-develop.ca to download EhPortal and for its support.

User Info

Welcome Guest.
Please log in.

Who's Online

  • Dot Guests: 1180
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

Recent Posts

Adding Forums Button to Nav bar by jirapon
[August 01, 2019, 09:07:12 AM]


Re: Board Icons by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 04:03:41 PM]


MOVED: Czech translation???? by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 03:04:51 PM]


Board Icons by jirapon
[July 30, 2019, 07:28:44 AM]


Re: Thankyou Simpleportal, by ♦ Ninja ZX-10RR ♦
[July 29, 2019, 09:41:29 AM]


Blocks speak! Do you have an interest in getting more blocks - or even making your own? The Blocks Board is for you!

User Stats Block Code

Started by Dallape, February 04, 2010, 05:33:46 PM

Previous topic - Next topic

0 Members and 3 Guests are viewing this topic.

Dallape

I need php code of this block, can someone give it to me? :)

Nathaniel

You should have the code within your Sources/PortalBlocks.template.php file. Search for the 'sp_userInfor' function.It should be the first function in that file.
SMF Friend (Former Support Specialist) | SimplePortal DeveloperMy SMF Mods | SimplePortal"Quis custodiet ipsos custodes?" - Who will Guard the Guards?Please don't send me ANY support related PMs. I will just delete them.

Dallape

Thanks, I have a code now. Can you tell me how to choose which member will be displayed. For example I want to display members
http://mysite.net/index.php?action=profile;u=1
and
http://mysite.net/index.php?action=profile;u=127

???

Nathaniel

Well, that will require some diffferent code. That block is only intended to show the user information about themselves.

Try the code below in a custom php block.

global $context, $txt, $scripturl, $memberContext, $modSettings, $user_info, $color_profile;

$users = array(1, 127);
foreach ($users as $user_id)
{
loadMemberData($user_id);
loadMemberContext($user_id);

$member_info = $memberContext[$user_id];

if (sp_loadColors($member_info['id']) !== false)
$member_info['colored_name'] = $color_profile[$member_info['id']]['colored_name'];

$member_info['karma']['total'] = $member_info['karma']['good'] - $member_info['karma']['bad'];

echo '
<strong>', !empty($member_info['colored_name']) ? $member_info['colored_name'] : $member_info['name'], '</strong>
<br /><br />';

if (!empty($member_info['avatar']['image']))
echo '
', $member_info['avatar']['image'], '<br /><br />';

if (!empty($member_info['group']))
echo '
', $member_info['group'], '<br />';
else
echo '
', $member_info['post_group'], '<br />';

echo '
', $member_info['group_stars'], '<br />';

echo '
<br />
<ul class="sp_list">';

echo '
<li>', sp_embed_image('dot'), ' <strong>', $txt[21], ':</strong> ', $member_info['posts'], '</li>';

if (!empty($modSettings['karmaMode']))
{
echo '
<li>', sp_embed_image('dot'), ' <strong>', $modSettings['karmaLabel'], '</strong> ';

if ($modSettings['karmaMode'] == 1)
echo $member_info['karma']['total'];
elseif ($modSettings['karmaMode'] == 2)
echo '+', $member_info['karma']['good'], '/-', $member_info['karma']['bad'];

echo '</li>';
}

if (allowedTo('pm_read'))
{
echo '
<li>', sp_embed_image('dot'), ' <strong>', $txt['sp-usertmessage'], ':</strong> <a href="', $scripturl, '?action=pm">', $context['user']['messages'], '</a></li>
<li>', sp_embed_image('dot'), ' <strong>', $txt['sp-usernmessage'], ':</strong> ', $context['user']['unread_messages'], '</li>';
}

echo '
<li>', sp_embed_image('dot'), ' <a href="', $scripturl, '?action=unread">', $txt['unread_topics_visit'], '</a></li>
<li>', sp_embed_image('dot'), ' <a href="', $scripturl, '?action=unreadreplies">', $txt['unread_replies'], '</a></li>';

echo '
</ul>
<br />';

echo '
', sp_embed_image('arrow'), ' <a href="', $scripturl, '?action=profile">', $txt[79], '</a> ', sp_embed_image('arrow'), ' <a href="', $scripturl, '?action=logout;sesc=', $context['session_id'], '">', $txt[108], '</a><br /><br />';
}
SMF Friend (Former Support Specialist) | SimplePortal DeveloperMy SMF Mods | SimplePortal"Quis custodiet ipsos custodes?" - Who will Guard the Guards?Please don't send me ANY support related PMs. I will just delete them.

ccbtimewiz

Nathaniel, that's a bit dirty to do (calling both loadMemberData and loadMemberContext) in a loop. You're just calling data not needed over and over again.

You could just lap up all the IDs you will load before. Eg...

   
   global $context, $txt, $scripturl, $memberContext, $modSettings, $user_info, $color_profile;

   $users = array(1, 127);
   loadMemberData($users);

   foreach ($users as $user_id)
   {
      loadMemberContext($user_id);

      $member_info = $memberContext[$user_id];

      if (sp_loadColors($member_info['id']) !== false)
         $member_info['colored_name'] = $color_profile[$member_info['id']]['colored_name'];

      $member_info['karma']['total'] = $member_info['karma']['good'] - $member_info['karma']['bad'];

      echo '
                           <strong>', !empty($member_info['colored_name']) ? $member_info['colored_name'] : $member_info['name'], '</strong>
                           <br /><br />';

      if (!empty($member_info['avatar']['image']))
         echo '
                           ', $member_info['avatar']['image'], '<br /><br />';

      if (!empty($member_info['group']))
         echo '
                           ', $member_info['group'], '<br />';
      else
         echo '
                           ', $member_info['post_group'], '<br />';

      echo '
                           ', $member_info['group_stars'], '<br />';

      echo '
                           <br />
                           <ul class="sp_list">';

      echo '
                              <li>', sp_embed_image('dot'), ' <strong>', $txt[21], ':</strong> ', $member_info['posts'], '</li>';

      if (!empty($modSettings['karmaMode']))
      {
         echo '
                              <li>', sp_embed_image('dot'), ' <strong>', $modSettings['karmaLabel'], '</strong> ';

         if ($modSettings['karmaMode'] == 1)
            echo $member_info['karma']['total'];
         elseif ($modSettings['karmaMode'] == 2)
            echo '+', $member_info['karma']['good'], '/-', $member_info['karma']['bad'];

         echo '</li>';
      }

      if (allowedTo('pm_read'))
      {
         echo '
                              <li>', sp_embed_image('dot'), ' <strong>', $txt['sp-usertmessage'], ':</strong> <a href="', $scripturl, '?action=pm">', $context['user']['messages'], '</a></li>
                              <li>', sp_embed_image('dot'), ' <strong>', $txt['sp-usernmessage'], ':</strong> ', $context['user']['unread_messages'], '</li>';
      }

      echo '
                              <li>', sp_embed_image('dot'), ' <a href="', $scripturl, '?action=unread">', $txt['unread_topics_visit'], '</a></li>
                              <li>', sp_embed_image('dot'), ' <a href="', $scripturl, '?action=unreadreplies">', $txt['unread_replies'], '</a></li>';

      echo '
                           </ul>
                           <br />';

      echo '
                           ', sp_embed_image('arrow'), ' <a href="', $scripturl, '?action=profile">', $txt[79], '</a> ', sp_embed_image('arrow'), ' <a href="', $scripturl, '?action=logout;sesc=', $context['session_id'], '">', $txt[108], '</a><br /><br />';
   }

Dallape

#5
Quote from: ccbtimewiz on February 07, 2010, 07:53:32 PM
Nathaniel, that's a bit dirty to do (calling both loadMemberData and loadMemberContext) in a loop. You're just calling data not needed over and over again.

You could just lap up all the IDs you will load before. Eg...

   
   global $context, $txt, $scripturl, $memberContext, $modSettings, $user_info, $color_profile;

   $users = array(1, 127);
   loadMemberData($users);

   foreach ($users as $user_id)
   {
      loadMemberContext($user_id);

      $member_info = $memberContext[$user_id];

      if (sp_loadColors($member_info['id']) !== false)
         $member_info['colored_name'] = $color_profile[$member_info['id']]['colored_name'];

      $member_info['karma']['total'] = $member_info['karma']['good'] - $member_info['karma']['bad'];

      echo '
                           <strong>', !empty($member_info['colored_name']) ? $member_info['colored_name'] : $member_info['name'], '</strong>
                           <br /><br />';

      if (!empty($member_info['avatar']['image']))
         echo '
                           ', $member_info['avatar']['image'], '<br /><br />';

      if (!empty($member_info['group']))
         echo '
                           ', $member_info['group'], '<br />';
      else
         echo '
                           ', $member_info['post_group'], '<br />';

      echo '
                           ', $member_info['group_stars'], '<br />';

      echo '
                           <br />
                           <ul class="sp_list">';

      echo '
                              <li>', sp_embed_image('dot'), ' <strong>', $txt[21], ':</strong> ', $member_info['posts'], '</li>';

      if (!empty($modSettings['karmaMode']))
      {
         echo '
                              <li>', sp_embed_image('dot'), ' <strong>', $modSettings['karmaLabel'], '</strong> ';

         if ($modSettings['karmaMode'] == 1)
            echo $member_info['karma']['total'];
         elseif ($modSettings['karmaMode'] == 2)
            echo '+', $member_info['karma']['good'], '/-', $member_info['karma']['bad'];

         echo '</li>';
      }

      if (allowedTo('pm_read'))
      {
         echo '
                              <li>', sp_embed_image('dot'), ' <strong>', $txt['sp-usertmessage'], ':</strong> <a href="', $scripturl, '?action=pm">', $context['user']['messages'], '</a></li>
                              <li>', sp_embed_image('dot'), ' <strong>', $txt['sp-usernmessage'], ':</strong> ', $context['user']['unread_messages'], '</li>';
      }

      echo '
                              <li>', sp_embed_image('dot'), ' <a href="', $scripturl, '?action=unread">', $txt['unread_topics_visit'], '</a></li>
                              <li>', sp_embed_image('dot'), ' <a href="', $scripturl, '?action=unreadreplies">', $txt['unread_replies'], '</a></li>';

      echo '
                           </ul>
                           <br />';

      echo '
                           ', sp_embed_image('arrow'), ' <a href="', $scripturl, '?action=profile">', $txt[79], '</a> ', sp_embed_image('arrow'), ' <a href="', $scripturl, '?action=logout;sesc=', $context['session_id'], '">', $txt[108], '</a><br /><br />';
   }


Yes, that's it... One more thing, now is displaying stats: Username, avatar, membergroup star, posts, karma, total messages, new messages, Recent  Unread Topics, Updated Topics profile and log out link. Can it be changed like on this picture:


And the members are one under other, and i need  one along other. How to do that? To be more specific, I need just like this picture.