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 login or register.

* Who's Online

  • Dot Guests: 380
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

* Shoutbox

Refresh History
  • Shoutbox is not for support!
  • {OCS}MasterSeal: Yup, Still adore SP
    April 21, 2019, 07:08:06 PM
  • {OCS}MasterSeal: STILL love SP :)
    November 24, 2018, 05:05:50 AM
  • ♦ Ninja ZX-10RR ♦: <3 aegersz
    September 13, 2018, 03:36:09 PM
  • aegersz: I STILL <3 LOVE SimplePortal
    September 13, 2018, 07:11:39 AM
  • aegersz: o LOVE you guys - Simple Portal rocks !
    May 09, 2018, 05:18:59 AM
  • Chen Zhen: our apologies for the site being down.. please read server issues topic
    March 22, 2018, 05:32:38 AM
  • {OCS}MasterSeal: LOL PLEASE forget I just posted that. I found the answer in my own dang post back in 2015. lol sorry!
    July 04, 2017, 10:47:55 PM
  • {OCS}MasterSeal: I know this SB isnt' for support, but I just have a general question. Who would I contact to find out where SP stores its block info? Is it DB driven or files? I searched the site but came up with nothing. probably my fault any insight is appreciated.
    July 04, 2017, 10:43:36 PM
  • ♦ Ninja ZX-10RR ♦: Excuse me but what does Simpleportal have to deal with that?
    February 05, 2017, 08:21:14 PM
  • WhiteEagle: of course IMHO that site appears to be dead :(
    February 04, 2017, 01:08:05 PM
  • WhiteEagle: If I can get that, then I'll use it for that site...
    February 04, 2017, 01:07:35 PM
  • WhiteEagle: decided to not use SMF for any projects, unless I can get a copy of the premium version of the fanfiction archive plugin
    February 04, 2017, 01:06:54 PM
  • expertdecisions: cloudflare
    January 28, 2017, 08:01:47 AM
  • aegersz: SM release 2.0.13 !
    January 12, 2017, 06:00:13 AM
  • raffo: Tks Emanuele, even if I didn't understand the fix :D
    November 07, 2016, 02:01:20 AM
  • emanuele: [link]
    November 01, 2016, 12:43:50 PM
  • emanuele: raffo: the English support board is a good place. ;)
    November 01, 2016, 12:43:38 PM
  • raffo: Where can I find the fix for the shoutbox?
    November 01, 2016, 05:06:09 AM
  • {OCS}MasterSeal: To the SP team, I make a point to come here and thank you as much as possible for your work.  so again, THANK YOU!
    October 28, 2016, 10:38:05 AM
  • emanuele: That's indeed funny, the limit is present only in the patch and not the full install.
    October 22, 2016, 06:14:58 PM

* 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]

Thanks for having an interest with our portal. If you have any requests for features, have a look at the Feature Requests board.

Author Topic: Displaying Message Icons On Portal  (Read 6473 times)

0 Members and 1 Guest are viewing this topic.

Offline worm82075

  • Semi Newbie
  • *
  • Posts: 19
  • Gender: Male
    • The Wormhole
  • SMF Version: 1.1.11
  • SP Version: 2.3.1
Displaying Message Icons On Portal
« on: March 03, 2010, 10:04:57 AM »
While I wait patiently for support I thought I might trouble you good folks further for some custom coding.
I've been using SimplePortal since it's inception. Originally it displayed message icons instead of sp specific post and topic icons. I use approximately 20 different custom icons to elude to the nature of topics and the posts within. I really need my message icons back on the portal. If anyone can point me in the right direction it would be much appreciated.

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Displaying Message Icons On Portal
« Reply #1 on: March 03, 2010, 10:12:56 AM »
Allude?
Where are you talking about displaying message icons on the portal?
In the Articles that are displayed between the top and bottom blocks?
In a "Recent Posts/Topics" block? or in an "Articles" block?
 
 
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Have you tried the SimplePortal documentation?

Offline worm82075

  • Semi Newbie
  • *
  • Posts: 19
  • Gender: Male
    • The Wormhole
  • SMF Version: 1.1.11
  • SP Version: 2.3.1
Re: Displaying Message Icons On Portal
« Reply #2 on: March 03, 2010, 10:50:34 AM »
Yes, allude. Sorry for my poor grammar.

I would like them to display in the recent posts and topics blocks.

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Displaying Message Icons On Portal
« Reply #3 on: March 03, 2010, 11:17:47 AM »
I think this can be adresssed in custom coding, in the same way that the articles block allows you to choose between category icon, poster avatar, or none.
 
This is actually not so difficult.
Do you know how to get started on this?
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Have you tried the SimplePortal documentation?

Offline worm82075

  • Semi Newbie
  • *
  • Posts: 19
  • Gender: Male
    • The Wormhole
  • SMF Version: 1.1.11
  • SP Version: 2.3.1
Re: Displaying Message Icons On Portal
« Reply #4 on: March 03, 2010, 11:36:34 AM »
Custom coding? As in custom PHP blocks? if so then no I haven't a clue. I'm pretty proficient at altering code under direction but writing it from scratch is a whole other ballgame.

If you are indeed referring to custom php blocks I could probably piece it together given time and research but that will have to wait as my site is currently without any admin controls for sp.

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Displaying Message Icons On Portal
« Reply #5 on: March 03, 2010, 12:47:37 PM »
OK.  I've recently done some custom coding in the Articles block, so this is fresh in my mind, so I think I can help. 
 
I'm pretty sure it is not that complicated.  I will get back to you after I check to make sure this is true!
 
I have other things going on today, but may have something for you to try tomorrow or Friday.
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Have you tried the SimplePortal documentation?

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Displaying Message Icons On Portal
« Reply #6 on: March 03, 2010, 08:20:15 PM »
Here's what I found out:
It is possible to have the topic icon for a recent TOPICS block, just using the existing tools.
 
To do that, I made some changes in sp_recent, in PortalBlocks.
See if you like this:
Code: [Select]
function sp_recent($parameters, $id, $return_parameters = false)
{
 global $context, $txt, $scripturl, $settings, $user_info, $color_profile;
 $block_parameters = array(
  'boards' => 'boards',
  'limit' => 'int',
  'type' => 'select',
  'display' => 'select',
  //AngelinaBelle
  'image' => 'select'
 );
 if ($return_parameters)
 {
 //AngelinaBelle
  $txt['sp_param_sp_recent_image'] = "Image:";
  $txt['sp_param_sp_recent_image_options'] = 'Standard Post/Topic|Message Icon';
  $helptxt['sp_param_sp_recent_image']= 'Display the standard Post/Topic icon, or the message icon';
 
  return $block_parameters;
 }
 $image = empty($parameters['image']) ? 0 : (int)$parameters['image'];
 $boards = !empty($parameters['boards']) ? explode('|', $parameters['boards']) : null;
 $limit = !empty($parameters['limit']) ? (int) $parameters['limit'] : 5;
 $type = 'ssi_recent' . (empty($parameters['type']) ? 'Posts' : 'Topics');
 $display = empty($parameters['display']) ? 'compact' : 'full';
//AngelinaBelle -- options for
 if (!empty($boards))
 {
  $temp_query_see_board = $user_info['query_see_board'];
  $user_info['query_see_board'] .= ' AND b.ID_BOARD IN (' . implode(', ', $boards) . ')';
 }
 $items = $type($limit, null, 'array');
 if (!empty($temp_query_see_board))
  $user_info['query_see_board'] = $temp_query_see_board;
 if (empty($items))
 {
  echo '
        ', $txt['error_sp_no_posts_found'];
  return;
 }
 else
  $items[count($items) - 1]['is_last'] = true;
 $colorids = array();
 foreach ($items as $item)
  $colorids[] = $item['poster']['id'];
 if (!empty($colorids) && sp_loadColors($colorids) !== false)
 {
  foreach ($items as $k => $p)
  {
   if (!empty($color_profile[$p['poster']['id']]['link']))
    $items[$k]['poster']['link'] = $color_profile[$p['poster']['id']]['link'];
  }
 }
 if ($display == 'compact')
 {
  foreach ($items as $key => $item)
   echo '
        <a href="', $item['href'], '">', $item['subject'], '</a> <span class="smalltext">', $txt[525], ' ', $item['poster']['link'], $item['new'] ? '' : ' <a href="' . $scripturl . '?topic=' . $item['topic'] . '.msg' . $item['new_from'] . ';topicseen#new" rel="nofollow"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $txt[302] . '" border="0" /></a>', '<br />[', $item['time'], ']</span><br />', empty($item['is_last']) ? '<hr />' : '';
 }
 elseif ($display == 'full')
 {
  echo '
        <table class="sp_fullwidth">';
  foreach ($items as $item)
  {
   //AngelinaBelle -- choose which image to use
   $item_image = (($image==0 || $parameters['type']=0 ) ? (sp_embed_image(empty($parameters['type']) ? 'post' : 'topic')) : $item['icon'] );
   echo '
         <tr>
          <td class="sp_recent_icon sp_center">
           ', $item_image, '
          </td>
          <td class="sp_recent_subject">
           <a href="', $item['href'], '">', $item['subject'], '</a>
           ', $item['new'] ? '' : '<a href="' . $scripturl . '?topic=' . $item['topic'] . '.msg' . $item['new_from'] . ';topicseen#new"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $txt[302] . '" border="0" /></a>', '<br />[', $item['board']['link'], ']
          </td>
          <td class="sp_recent_info sp_right">
           ', $item['poster']['link'], '<br />', $item['time'], '
          </td>
         </tr>';
  }
  echo '
        </table>';
 }
}

If you need this also for recent POSTS, then the work also requires a change to SSI.php.  I am not so experienced and bold with SMF to feel confident changing things that might be called by lots of other things, so I am a little hesitant to do it. I could do it. It would be easy...
 
Remember, please, to save a copy of your current version of PortalBlocks.php.
Then replace the function sp_recent with the one I just made. If you don't like it, you can always switch back.
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Have you tried the SimplePortal documentation?

Offline Chen Zhen

  • The Underdog
  • Operations Manager
  • *
  • Posts: 1350
  • Gender: Male
  • Kinesis
    • WebDev
  • SMF Version: 2.1
  • EhPortal Version: 1.22
Re: Displaying Message Icons On Portal
« Reply #7 on: March 06, 2010, 12:14:24 AM »

If you need this also for recent POSTS, then the work also requires a change to SSI.php.  I am not so experienced and bold with SMF to feel confident changing things that might be called by lots of other things, so I am a little hesitant to do it. I could do it. It would be easy...
 
Remember, please, to save a copy of your current version of PortalBlocks.php.
Then replace the function sp_recent with the one I just made. If you don't like it, you can always switch back.

IMAO - When you need to use a function but want to change it, just copy the whole sub-routine into a block.
Change the name of the function and make your edits.

To execute it, simply call it.
 Sometimes a few variables need to be predefined before calling a function, but not in all cases.

ie. for the above code try this:
Code: [Select]
/*  Recent messages block with topic icons (if your theme uses them) */
/* For SMF 1.1.1x and Simple Portal 2.3.1 */

sp_recent_2($parameters, $id, $return_parameters = false);

function sp_recent_2($parameters, $id, $return_parameters = false)
{
 global $context, $txt, $scripturl, $settings, $user_info, $color_profile;
 $block_parameters = array(
  'boards' => 'boards',
  'limit' => 'int',
  'type' => 'select',
  'display' => 'select',
  'image' => 'select',
 );
 if ($return_parameters)
 {
 /* AngelinaBelle */
  $txt['sp_param_sp_recent_image'] = 'Image:';
  $txt['sp_param_sp_recent_image_options'] = 'Standard Post/Topic|Message Icon';
  $helptxt['sp_param_sp_recent_image'] = 'Display the standard Post/Topic icon, or the message icon';
 
  return $block_parameters;
 }
 $image = empty($parameters['image']) ? 0 : (int)$parameters['image'];
 $boards = !empty($parameters['boards']) ? explode('|', $parameters['boards']) : null;
 $limit = !empty($parameters['limit']) ? (int) $parameters['limit'] : 5;
 $type = 'ssi_recent' . (empty($parameters['type']) ? 'Posts' : 'Topics');
 $display = empty($parameters['display']) ? 'compact' : 'full';
/* AngelinaBelle -- options for */
 if (!empty($boards))
 {
  $temp_query_see_board = $user_info['query_see_board'];
  $user_info['query_see_board'] .= ' AND b.ID_BOARD IN (' . implode(', ', $boards) . ')';
 }
 $items = $type($limit, null, 'array');
 if (!empty($temp_query_see_board))
  $user_info['query_see_board'] = $temp_query_see_board;
 if (empty($items))
 {
  echo '
        ', $txt['error_sp_no_posts_found'];
  return;
 }
 else
  $items[count($items) - 1]['is_last'] = true;
 $colorids = array();
 foreach ($items as $item)
  $colorids[] = $item['poster']['id'];
 if (!empty($colorids) && sp_loadColors($colorids) !== false)
 {
  foreach ($items as $k => $p)
  {
   if (!empty($color_profile[$p['poster']['id']]['link']))
    $items[$k]['poster']['link'] = $color_profile[$p['poster']['id']]['link'];
  }
 }
 if ($display == 'compact')
 {
  foreach ($items as $key => $item)
   echo '
        <a href="', $item['href'], '">', $item['subject'], '</a> <span class="smalltext">', $txt[525], ' ', $item['poster']['link'], $item['new'] ? '' : ' <a href="' . $scripturl . '?topic=' . $item['topic'] . '.msg' . $item['new_from'] . ';topicseen#new" rel="nofollow"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $txt[302] . '" border="0" /></a>', '<br />[', $item['time'], ']</span><br />', empty($item['is_last']) ? '<hr />' : '';
 }
 elseif ($display == 'full')
 {
  echo '
        <table class="sp_fullwidth">';
  foreach ($items as $item)
  {
   /* AngelinaBelle -- choose which image to use */
   $item_image = (($image==0 || $parameters['type']=0 ) ? (sp_embed_image(empty($parameters['type']) ? 'post' : 'topic')) : $item['icon'] );
   echo '
         <tr>
          <td class="sp_recent_icon sp_center">
           ', $item_image, '
          </td>
          <td class="sp_recent_subject">
           <a href="', $item['href'], '">', $item['subject'], '</a>
           ', $item['new'] ? '' : '<a href="' . $scripturl . '?topic=' . $item['topic'] . '.msg' . $item['new_from'] . ';topicseen#new"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $txt[302] . '" border="0" /></a>', '<br />[', $item['board']['link'], ']
          </td>
          <td class="sp_recent_info sp_right">
           ', $item['poster']['link'], '<br />', $item['time'], '
          </td>
         </tr>';
  }
  echo '
        </table>';
 }
}

worm82075:

If I understand you correctly, your custom theme has topic icons and this I assume will display them.
Currently for testing I do not have a theme that has topic icons installed on any of my SMF 1.1.1x versions, therefore I was not able to test this fully as of yet. (I tested it but all my current themes only display text for thread headers)

What theme are you using worm82075?  If I install the same theme on one of my SMF 1.1.1x test forums I can test this fully.

UD
« Last Edit: March 06, 2010, 12:16:26 AM by Underdog »

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Displaying Message Icons On Portal
« Reply #8 on: March 06, 2010, 02:01:11 PM »
IMAO - When you need to use a function but want to change it, just copy the whole sub-routine into a block.
Change the name of the function and make your edits.

To execute it, simply call it.
Yeah -- good point. A renamed SSI function replacement won't interfere with anything calling the SSI function. Especially if I don't even put it in SSI.
 
I'm just awfully timid.
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Have you tried the SimplePortal documentation?

Offline worm82075

  • Semi Newbie
  • *
  • Posts: 19
  • Gender: Male
    • The Wormhole
  • SMF Version: 1.1.11
  • SP Version: 2.3.1
Re: Displaying Message Icons On Portal
« Reply #9 on: March 06, 2010, 08:25:20 PM »
All of my themes are based off of my default so that each theme need only have it's own images and an index.template.php.

Are we talking about the same icons?  I'm talking about the smf message icons. You know;, , , , etc...etc....

See the pic attached. I'd like to see my custom icons back on the portal like they were originally at SP's inception.

Offline Chen Zhen

  • The Underdog
  • Operations Manager
  • *
  • Posts: 1350
  • Gender: Male
  • Kinesis
    • WebDev
  • SMF Version: 2.1
  • EhPortal Version: 1.22
Re: Displaying Message Icons On Portal
« Reply #10 on: March 06, 2010, 09:05:13 PM »
All of my themes are based off of my default so that each theme need only have it's own images and an index.template.php.

Are we talking about the same icons?  I'm talking about the smf message icons. You know;, , , , etc...etc....

See the pic attached. I'd like to see my custom icons back on the portal like they were originally at SP's inception.

Some themes have icons for each board (graphic pics or graphic text - whatever).. I am going to check out your forum and run a test site with the same SMF version and theme. I see it is the topic icons you want displayed.

Angelina - When copying a whole function, renaming it and using it in the block there is nothing to be timid about since no existing files are being tampered with.   ;)
 

UD
« Last Edit: March 06, 2010, 09:22:00 PM by Underdog »

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Displaying Message Icons On Portal
« Reply #11 on: March 07, 2010, 08:04:49 AM »
Underdog,
It never even occured to me that putting a renamed block function in a block would even work. Some parts of SimplePortal, I haven't traced through yet.
 
If you are running with this, I'll leave it.
 
worm82075
Looks like Underdog is running with the ball, now.
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Have you tried the SimplePortal documentation?

Offline Chen Zhen

  • The Underdog
  • Operations Manager
  • *
  • Posts: 1350
  • Gender: Male
  • Kinesis
    • WebDev
  • SMF Version: 2.1
  • EhPortal Version: 1.22
Re: Displaying Message Icons On Portal
« Reply #12 on: March 08, 2010, 11:21:50 PM »
Underdog,
It never even occured to me that putting a renamed block function in a block would even work. Some parts of SimplePortal, I haven't traced through yet.
 
If you are running with this, I'll leave it.
 
worm82075
Looks like Underdog is running with the ball, now.

Gee thanks.   :0  lol.

I was just pointing out how you can copy functions and change/use them without having to edit any php files.

I will finish this up later this week when I have more time.

UD

 

« Last Edit: March 09, 2010, 01:06:33 AM by Underdog »

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Displaying Message Icons On Portal
« Reply #13 on: March 09, 2010, 10:24:28 AM »
Oh! when you said you were testing it out on your own test forum, I figured you had written some code. Since you seem to be more experienced than me, I figured that was a good thing. I'm still around.  Just shout.
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Have you tried the SimplePortal documentation?

Offline Chen Zhen

  • The Underdog
  • Operations Manager
  • *
  • Posts: 1350
  • Gender: Male
  • Kinesis
    • WebDev
  • SMF Version: 2.1
  • EhPortal Version: 1.22
Re: Displaying Message Icons On Portal
« Reply #14 on: March 12, 2010, 04:47:17 PM »
Try this...

Code: [Select]
/*  Recent Posts block for SMF 1.1.1x  */

global $context, $settings, $scripturl, $txt, $db_prefix, $ID_MEMBER, $user_info, $modSettings, $func, $boardurl;

/* Adjustable variables */
$paramters = array();
$numPosts = 10;
$exclude_boards = null;
$format = 'vertical';
$msg_new = '[new]';
$postby = 'Posted By:';
$intro_statement = '';
$end_statement = '';
$showColor = true;   
$default_icon = 'xx';
$numPosts = (int) $numPosts;

/*  Main code  */   
   
   // Pass all the parematers
   foreach($paramters as $myparam)
   {
      if ($myparam['parameter_name'] == 'format')
         $format =  $myparam['data'];
      if ($myparam['parameter_name'] == 'numPosts')
         $numPosts = (int) $myparam['data'];
      if ($myparam['parameter_name'] == 'showcolor')
      {
         if ($myparam['data'] == 'true')
            $showColor = true;
         else
            $showColor = false;
      }
   
   }
/* Intro Statement */   
   echo $intro_statement;

   if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0)
      $exclude_boards = array($modSettings['recycle_board']);
   else
      $exclude_boards = empty($exclude_boards) ? array() : $exclude_boards;

   /*  Query all the posts  */
   $request = db_query("
      SELECT
         m.posterTime, m.subject, m.ID_TOPIC, m.ID_MEMBER, m.ID_MSG, icon, m.ID_BOARD, b.name AS bName, mg.onlineColor, mg.ID_GROUP,
         IFNULL(mem.realName, m.posterName) AS posterName, " . ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
         IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) >= m.ID_MSG_MODIFIED AS isRead,
         IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . ", LEFT(m.body, 384) AS body, m.smileysEnabled
      FROM ({$db_prefix}messages AS m, {$db_prefix}boards AS b)
         LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)
          LEFT JOIN {$db_prefix}membergroups AS mg ON (mg.ID_GROUP = IF(mem.ID_GROUP = 0, mem.ID_POST_GROUP, mem.ID_GROUP))
         
         " . (!$user_info['is_guest'] ? "
         LEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = m.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
         LEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = m.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)" : '') . "
      WHERE m.ID_MSG >= " . ($modSettings['maxMsgID'] - 25 * min($numPosts, 5)) . "
         AND b.ID_BOARD = m.ID_BOARD" . (empty($exclude_boards) ? '' : "
         AND b.ID_BOARD NOT IN (" . implode(', ', $exclude_boards) . ")") . "
         AND $user_info[query_see_board]
      ORDER BY m.ID_MSG DESC
      LIMIT $numPosts", __FILE__, __LINE__);
   $posts = array();
   while ($row = mysql_fetch_assoc($request))
   {
if ($row['icon'] == false)
{$row['icon'] = $default_icon;}
      $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileysEnabled'], $row['ID_MSG']), array('<br />' => '
')));
      if ($func['strlen']($row['body']) > 128)
         $row['body'] = $func['substr']($row['body'], 0, 128) . '...';

      /*  Censor the post info  */
      censorText($row['subject']);
      censorText($row['body']);
      /*  Feed the array with the info from the db  */
      $posts[] = array(
         'board' => array(
            'id' => $row['ID_BOARD'],
            'name' => $row['bName'],
            'href' => $scripturl . '?board=' . $row['ID_BOARD'] . '.0',
            'link' => '<a href="' . $scripturl . '?board=' . $row['ID_BOARD'] . '.0">' . $row['bName'] . '</a>'
         ),
         'topic' => $row['ID_TOPIC'],
                        'icon' => '<img src="' . $boardurl.'/Themes/default/images/post/'.$row['icon'].'.gif" alt="~" title="'.$row['subject'].'" border="0" />',
         'poster' => array(
            'id' => $row['ID_MEMBER'],
            'name' => $row['posterName'],
            'href' => empty($row['ID_MEMBER']) ? '' : $scripturl . '?action=profile;u=' . $row['ID_MEMBER'],
            'link' => empty($row['ID_MEMBER']) ? $row['posterName'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['posterName'] . '</a>',
            'colorlink'  => empty($row['ID_MEMBER']) ? $row['posterName'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '"><font color="' . $row['onlineColor'] . '">' . $row['posterName'] . '</font></a>',
         ),
         'subject' => $row['subject'],
         'short_subject' => shorten_subject($row['subject'], 25),
         'preview' => $row['body'],
         'time' => timeformat($row['posterTime']),
         'timestamp' => forum_time(true, $row['posterTime']),
         'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . ';topicseen#new',
         'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . '#msg' . $row['ID_MSG'] . '">' . $row['subject'] . '</a>',
         'new' => !empty($row['isRead']),
         'new_from' => $row['new_from'],
      );
   }
   mysql_free_result($request);
   
   
   if  (empty($posts))
      return;

   echo '
      <table border="0">';
   
   if ($format == 'vertical')
   {
      foreach ($posts as $post)
      {
         
         echo '
            <tr>
               <td valign="top">
                 
                  '.$post['icon'].'</td><td valign="top"><span class="smalltext"><a href="', $post['href'], '"><b>', $post['subject'], '</b></a>
                  ', $postby, ' ', ($showColor == true ? $post['poster']['colorlink'] : $post['poster']['link']), '
                  ', $post['new'] ? '' : '<a href="' . $scripturl . '?topic=' . $post['topic'] . '.msg' . $post['new_from'] . ';topicseen#new"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $msg_new . '" border="0" /></a>', '
                  <br />', $post['time'], '
                  </span>
                  <hr />
               </td>
         
            </tr>';
      }
   }
   else
   {
      foreach ($posts as $post)
         echo '
            <tr>
               <td align="right" valign="top">
                  [', $post['board']['link'], ']
               </td>
               <td valign="top">
                  <a href="', $post['href'], '">', $post['subject'], '</a>
                  ', $postby, ' ', ($showColor == true ? $post['poster']['colorlink'] : $post['poster']['link']), '
                  ', $post['new'] ? '' : '<a href="' . $scripturl . '?topic=' . $post['topic'] . '.msg' . $post['new_from'] . ';topicseen#new"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $msg_new . '" border="0" /></a>', '
               </td>
               <td align="right" nowrap="nowrap">
                  ', $post['time'], '
               </td>
            </tr>';
   }
   echo '
      </table>';
   
   
   
/* Ending Statement */
   echo $end_statement;


You can make some specific adjustments from the top of the block.

UD
« Last Edit: March 13, 2010, 05:31:24 PM by Underdog »

Offline Chen Zhen

  • The Underdog
  • Operations Manager
  • *
  • Posts: 1350
  • Gender: Male
  • Kinesis
    • WebDev
  • SMF Version: 2.1
  • EhPortal Version: 1.22
Re: Displaying Message Icons On Portal
« Reply #15 on: March 13, 2010, 11:51:37 PM »

Worm -
Does this block work the way you want?

If so.. mark the thread solved.


UD

Offline worm82075

  • Semi Newbie
  • *
  • Posts: 19
  • Gender: Male
    • The Wormhole
  • SMF Version: 1.1.11
  • SP Version: 2.3.1
Re: Displaying Message Icons On Portal
« Reply #16 on: March 14, 2010, 12:03:24 PM »
Yes it does work well but I would also like the same functionality for recent topics. Perhaps another variable that defines posts or topics. Thanks by the way.

Offline Chen Zhen

  • The Underdog
  • Operations Manager
  • *
  • Posts: 1350
  • Gender: Male
  • Kinesis
    • WebDev
  • SMF Version: 2.1
  • EhPortal Version: 1.22
Re: Displaying Message Icons On Portal
« Reply #17 on: March 14, 2010, 10:44:43 PM »
Recent Topics and Posts Block for SMF 1.1.1x

Adjustments can be set in the top of the block.

Imao - Set up the block with No Title from the style options at the bottom while editing the block.

PHP Portal Block:
Code: [Select]
/*  START - SMF 1.1.1x Recent Topics and Posts Block  */


/*             Adjustable variables        */
/* Set $numPosts or $numTopics to 0 to disable */
$paramters = array();
$numPosts = 10;
$numTopics = 10;
$exclude_boards_topics = null;
$exclude_boards_posts = null;
$format = 'vertical';
$msg_new = '[new]';
$postby = 'Posted By:';
$showColor = true;   
$default_icon = 'xx';

/* Get globals and set (int) for max */

global $context, $settings, $scripturl, $db_prefix, $ID_MEMBER, $user_info, $modSettings, $func, $boardurl;
$numPosts = (int) $numPosts;
$numTopics = (int) $numTopics;

/*  These are for the images used in the titles below */
$posts_icon = $boardurl.'/Themes/default/images/post/xx.gif';
$topics_icon = $boardurl.'/Themes/default/images/topic/normal_post.gif';

/* These are the titles and/or ending statements */
$intro_posts = '<div class="smalltext" style="text-align: center; color: #216095;"><img src="'.$posts_icon.'" alt="" title="Recent Posts" width="16" height="16" /><strong>Recent Posts</strong></div><hr />';
$ending_posts = '<br />';
$intro_topics = '<div class="smalltext" style="text-align: center; color: #216095;"><img src="'.$topics_icon.'" alt="" title="Recent Topics" width="16" height="16" /><strong>Recent Topics</strong></div><hr />';
$ending_topics = '<br />';

/*  START - Recent Posts  */     
if ($numPosts > 0)
{   
   foreach($paramters as $myparam)
   {
      if ($myparam['parameter_name'] == 'format')
         $format =  $myparam['data'];
      if ($myparam['parameter_name'] == 'numPosts')
         $numPosts = (int) $myparam['data'];
      if ($myparam['parameter_name'] == 'showcolor')
      {
         if ($myparam['data'] == 'true')
            $showColor = true;
         else
            $showColor = false;
      }
   
   }
/* Intro Statement */   
   echo $intro_posts;

   if ($exclude_boards_posts === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0)
      $exclude_boards_posts = array($modSettings['recycle_board']);
   else
      $exclude_boards_posts = empty($exclude_boards_posts) ? array() : $exclude_boards_posts;
   
   $request = db_query("
      SELECT
         m.posterTime, m.subject, m.ID_TOPIC, m.ID_MEMBER, m.ID_MSG, icon, m.ID_BOARD, b.name AS bName, mg.onlineColor, mg.ID_GROUP,
         IFNULL(mem.realName, m.posterName) AS posterName, " . ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
         IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) >= m.ID_MSG_MODIFIED AS isRead,
         IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . ", LEFT(m.body, 384) AS body, m.smileysEnabled
      FROM ({$db_prefix}messages AS m, {$db_prefix}boards AS b)
         LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)
          LEFT JOIN {$db_prefix}membergroups AS mg ON (mg.ID_GROUP = IF(mem.ID_GROUP = 0, mem.ID_POST_GROUP, mem.ID_GROUP))
         
         " . (!$user_info['is_guest'] ? "
         LEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = m.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
         LEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = m.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)" : '') . "
      WHERE m.ID_MSG >= " . ($modSettings['maxMsgID'] - 25 * min($numPosts, 5)) . "
         AND b.ID_BOARD = m.ID_BOARD" . (empty($exclude_boards_posts) ? '' : "
         AND b.ID_BOARD NOT IN (" . implode(', ', $exclude_boards_posts) . ")") . "
         AND $user_info[query_see_board]
      ORDER BY m.ID_MSG DESC
      LIMIT $numPosts", __FILE__, __LINE__);
   $posts = array();
   while ($row = mysql_fetch_assoc($request))
   {
if ($row['icon'] == false)
{$row['icon'] = $default_icon;}
      $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileysEnabled'], $row['ID_MSG']), array('<br />' => '
')));
      if ($func['strlen']($row['body']) > 128)
         $row['body'] = $func['substr']($row['body'], 0, 128) . '...';

      /*  Censor post subject  */
      censorText($row['subject']);
      censorText($row['body']);
     
      $posts[] = array(
         'board' => array(
            'id' => $row['ID_BOARD'],
            'name' => $row['bName'],
            'href' => $scripturl . '?board=' . $row['ID_BOARD'] . '.0',
            'link' => '<a href="' . $scripturl . '?board=' . $row['ID_BOARD'] . '.0">' . $row['bName'] . '</a>'
         ),
         'topic' => $row['ID_TOPIC'],
                        'icon' => '<img src="' . $boardurl.'/Themes/default/images/post/'.$row['icon'].'.gif" alt="~" title="'.$row['subject'].'" border="0" />',
         'poster' => array(
            'id' => $row['ID_MEMBER'],
            'name' => $row['posterName'],
            'href' => empty($row['ID_MEMBER']) ? '' : $scripturl . '?action=profile;u=' . $row['ID_MEMBER'],
            'link' => empty($row['ID_MEMBER']) ? $row['posterName'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['posterName'] . '</a>',
            'colorlink'  => empty($row['ID_MEMBER']) ? $row['posterName'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '"><font color="' . $row['onlineColor'] . '">' . $row['posterName'] . '</font></a>',
         ),
         'subject' => $row['subject'],
         'short_subject' => shorten_subject($row['subject'], 25),
         'preview' => $row['body'],
         'time' => timeformat($row['posterTime']),
         'timestamp' => forum_time(true, $row['posterTime']),
         'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . ';topicseen#new',
         'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . '#msg' . $row['ID_MSG'] . '">' . $row['subject'] . '</a>',
         'new' => !empty($row['isRead']),
         'new_from' => $row['new_from'],
      );
   }
   mysql_free_result($request);
   
   
   if  (empty($posts))
      return;

   echo '
      <table border="0">';
   
   if ($format == 'vertical')
   {
      foreach ($posts as $post)
      {
         
         echo '
            <tr>
               <td valign="top">
                 
                  '.$post['icon'].'</td><td valign="top"><span class="smalltext"><a href="', $post['href'], '"><b>', $post['subject'], '</b></a>
                  ', $postby, ' ', ($showColor == true ? $post['poster']['colorlink'] : $post['poster']['link']), '
                  ', $post['new'] ? '' : '<a href="' . $scripturl . '?topic=' . $post['topic'] . '.msg' . $post['new_from'] . ';topicseen#new"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $msg_new . '" border="0" /></a>', '
                  <br />', $post['time'], '
                  </span>
                  <hr />
               </td>
         
            </tr>';
      }
   }
   else
   {
      foreach ($posts as $post)
         echo '
            <tr>
               <td align="right" valign="top">
                  [', $post['board']['link'], ']
               </td>
               <td valign="top">
                  <a href="', $post['href'], '">', $post['subject'], '</a>
                  ', $postby, ' ', ($showColor == true ? $post['poster']['colorlink'] : $post['poster']['link']), '
                  ', $post['new'] ? '' : '<a href="' . $scripturl . '?topic=' . $post['topic'] . '.msg' . $post['new_from'] . ';topicseen#new"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $msg_new . '" border="0" /></a>', '
               </td>
               <td align="right" nowrap="nowrap">
                  ', $post['time'], '
               </td>
            </tr>';
   }
   echo '
      </table>';   
   
/* Ending Statement */
   echo $ending_posts;
}
/*  END - Recent Posts  */

/*  START - Recent Topics  */   
if ($numTopics > 0)
{   
   foreach($paramters as $myparam)
   {
      if ($myparam['parameter_name'] == 'format')
         $format =  $myparam['data'];
      if ($myparam['parameter_name'] == 'numTopics')
         $numTopics = (int) $myparam['data'];
      if ($myparam['parameter_name'] == 'showcolor')
      {
         if ($myparam['data'] == 'true')
            $showColor = true;
         else
            $showColor = false;
      }
     
   }
   
   echo $intro_topics;


   if ($exclude_boards_topics === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0)
      $exclude_boards_topics = array($modSettings['recycle_board']);
   else
      $exclude_boards_topics = empty($exclude_boards_topics) ? array() : $exclude_boards_topics;

   $stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
   $icon_sources = array();
   foreach ($stable_icons as $icon)
      $icon_sources[$icon] = 'images_url';
   
   $request = db_query("
      SELECT
         m.posterTime, ms.subject, m.ID_TOPIC, m.ID_MEMBER, m.ID_MSG, b.ID_BOARD, b.name AS bName, mg.onlineColor, mg.ID_GROUP,
         IFNULL(mem.realName, m.posterName) AS posterName, " . ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
         IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) >= m.ID_MSG_MODIFIED AS isRead,
         IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . ", LEFT(m.body, 384) AS body, m.smileysEnabled, m.icon
      FROM ({$db_prefix}messages AS m, {$db_prefix}topics AS t, {$db_prefix}boards AS b, {$db_prefix}messages AS ms)
         LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)
         LEFT JOIN {$db_prefix}membergroups AS mg ON (mg.ID_GROUP = IF(mem.ID_GROUP = 0, mem.ID_POST_GROUP, mem.ID_GROUP))
         " . (!$user_info['is_guest'] ? "
         LEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
         LEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = b.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)" : '') . "
      WHERE t.ID_LAST_MSG >= " . ($modSettings['maxMsgID'] - 35 * min($numTopics, 5)) . "
         AND t.ID_LAST_MSG = m.ID_MSG
         AND b.ID_BOARD = t.ID_BOARD" . (empty($exclude_boards_topics) ? '' : "
         AND b.ID_BOARD NOT IN (" . implode(', ', $exclude_boards_topics) . ")") . "
         AND $user_info[query_see_board]
         AND ms.ID_MSG = t.ID_FIRST_MSG
      ORDER BY t.ID_LAST_MSG DESC
      LIMIT $numTopics", __FILE__, __LINE__);
   $posts = array();
   while ($row = mysql_fetch_assoc($request))
   {
if ($row['icon'] == false)
{$row['icon'] = $default_icon;}
      $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileysEnabled'], $row['ID_MSG']), array('<br />' => '
')));
      if ($func['strlen']($row['body']) > 128)
         $row['body'] = $func['substr']($row['body'], 0, 128) . '...';

      /* Censor the subject */
      censorText($row['subject']);
      censorText($row['body']);

      if (empty($modSettings['messageIconChecks_disable']) && !isset($icon_sources[$row['icon']]))
         $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.gif') ? 'images_url' : 'default_images_url';
     
      $posts[] = array(
         'board' => array(
            'id' => $row['ID_BOARD'],
            'name' => $row['bName'],
            'href' => $scripturl . '?board=' . $row['ID_BOARD'] . '.0',
            'link' => '<a href="' . $scripturl . '?board=' . $row['ID_BOARD'] . '.0">' . $row['bName'] . '</a>'
         ),
         'topic' => $row['ID_TOPIC'],
         'poster' => array(
            'id' => $row['ID_MEMBER'],
            'name' => $row['posterName'],
            'href' => empty($row['ID_MEMBER']) ? '' : $scripturl . '?action=profile;u=' . $row['ID_MEMBER'],
            'link' => empty($row['ID_MEMBER']) ? $row['posterName'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['posterName'] . '</a>',
            'colorlink'  => empty($row['ID_MEMBER']) ? $row['posterName'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '"><font color="' . $row['onlineColor'] . '">' . $row['posterName'] . '</font></a>',
         ),
         'subject' => $row['subject'],
         'short_subject' => shorten_subject($row['subject'], 25),
         'preview' => $row['body'],
         'time' => timeformat($row['posterTime']),
         'timestamp' => forum_time(true, $row['posterTime']),
         'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . ';topicseen#new',
         'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . '#new">' . $row['subject'] . '</a>',
         'new' => !empty($row['isRead']),
         'new_from' => $row['new_from'],
         'icon' => '<img src="' . $settings[$icon_sources[$row['icon']]] . '/post/' . $row['icon'] . '.gif" align="middle" alt="~" title ="'.$row['subject'].'" border="0" />',
      );
   }
   mysql_free_result($request);
   
   if  (empty($posts))
      return;

   echo '
      <table border="0">';
   
   if ($format == 'vertical')
   {
      foreach ($posts as $post)
      {     
         echo '
            <tr>
               <td valign="top">
                 
                  '.$post['icon'].'</td><td valign="top"><span class="smalltext"><a href="', $post['href'], '"><b>', $post['subject'], '</b></a>
                  ', $postby, ' ', ($showColor == true ? $post['poster']['colorlink'] : $post['poster']['link']), '
                  ', $post['new'] ? '' : '<a href="' . $scripturl . '?topic=' . $post['topic'] . '.msg' . $post['new_from'] . ';topicseen#new"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $msg_new . '" border="0" /></a>', '
                  <br />', $post['time'], '
                  </span>
                  <hr />
               </td>
         
            </tr>';
      }
   }
   else
   {
      foreach ($posts as $post)
         echo '
            <tr>
               <td align="right" valign="top">
                  [', $post['board']['link'], ']
               </td>
               <td valign="top">
                  <a href="', $post['href'], '">', $post['subject'], '</a>
                  ', $postby, ' ', ($showColor == true ? $post['poster']['colorlink'] : $post['poster']['link']), '
                  ', $post['new'] ? '' : '<a href="' . $scripturl . '?topic=' . $post['topic'] . '.msg' . $post['new_from'] . ';topicseen#new"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $msg_new . '" border="0" /></a>', '
               </td>
               <td align="right" nowrap="nowrap">
                  ', $post['time'], '
               </td>
            </tr>';
   }
   echo '
      </table>';   
   
   echo $ending_topics;
}
/*  END - Recent Topics  */

/*  END - SMF 1.1.1x Recent Topics and Posts Block  */

<<<<<<<<<<>>>>>>>>>>

If you want the Topics to also display the most recent posts icon in that topic...

In the above code, Find:
Code: [Select]
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . ", LEFT(m.body, 384) AS body, m.smileysEnabled, m.icon

Replace with:
Code: [Select]
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . ", LEFT(m.body, 384) AS body, m.smileysEnabled, ms.icon


UD
« Last Edit: March 15, 2010, 01:38:02 AM by Underdog »

Offline MultiformeIngegno

  • Full Member
  • ***
  • Posts: 127
  • Gender: Male
  • SMF Version: None
  • SP Version: None
Re: Displaying Message Icons On Portal
« Reply #18 on: March 15, 2010, 05:47:59 AM »
A chance of having this for rc3....? :)