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: 371
  • 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]

Installation errors? Mod incompatibilities? Upgrade problems? Make your way over to the Install and Upgrade Support board for all your solutions!

Author Topic: [Block] Recent Topics/Posts with Post Preview!  (Read 176472 times)

0 Members and 3 Guests are viewing this topic.

Offline Blue

  • Customizer
  • *
  • Posts: 379
  • Gender: Male
  • Block Maker? =P
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #120 on: November 25, 2012, 08:35:34 PM »
Block updated :D Version 1.6 (see first post)

Added the possibility to show the vertical scrollbar with the height that you want ;)
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Offline FrizzleFried

  • Full Member
  • ***
  • Posts: 114
  • SMF Version: 2.0.5
  • SP Version: 2.3.5
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #121 on: November 26, 2012, 01:52:39 PM »
Thank you!


Offline Blue

  • Customizer
  • *
  • Posts: 379
  • Gender: Male
  • Block Maker? =P
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #122 on: November 26, 2012, 06:36:08 PM »
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Offline Ahmad Rasyid Ismail

  • Translator
  • *
  • Posts: 61
  • Gender: Male
    • Need Free SMF Support?
  • SMF Version: 2.0.2
  • SP Version: 2.3.5
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #123 on: December 19, 2012, 12:17:21 AM »
A very very nice mod.

Offline Mick.

  • Comrade
  • *
  • Posts: 77
  • Gender: Male
  • Premium SMF Themes
    • idesignSMF
  • SMF Version: 2.0.15
  • SP Version: 2.3.7
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #124 on: December 26, 2012, 07:37:16 PM »
Yup. One of my favorite blocks ;)

Offline Mick.

  • Comrade
  • *
  • Posts: 77
  • Gender: Male
  • Premium SMF Themes
    • idesignSMF
  • SMF Version: 2.0.15
  • SP Version: 2.3.7
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #125 on: January 01, 2013, 11:21:17 AM »
One thing i found is, when posting an image url inside the image tags, the image url shows on the block.  FYI.

Offline kimyaci

  • Full Member
  • ***
  • Posts: 127
  • Gender: Male
    • Forumigo8navigation
  • SMF Version: 2.0.7
  • SP Version: 2.3.5
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #126 on: January 01, 2013, 08:32:06 PM »
Hi Blue
Thank you very much for this block.But it does not look good links.Only text seem more beautiful.

SMF 2.0.7 HabboArtv1, Default Themes.

Offline dhayzon

  • Jr. Member
  • **
  • Posts: 63
  • Gender: Male
  • http://dhayzon.com/
    • wWw.club-dhayzone.net
  • SMF Version: 2.0.2
  • SP Version: 2.3.5
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #127 on: January 09, 2013, 10:25:26 AM »
I'm playing a little
but how would it?





Offline Blue

  • Customizer
  • *
  • Posts: 379
  • Gender: Male
  • Block Maker? =P
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #128 on: January 13, 2013, 09:52:08 PM »
One thing i found is, when posting an image url inside the image tags, the image url shows on the block.  FYI.

Thank you for the feedback, I'll fix it :)
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Offline teos

  • Jr. Member
  • **
  • Posts: 57
  • Gender: Male
    • Cultural Heritage photographer
  • SMF Version: 2.0.2
  • SP Version: 2.3.5
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #129 on: January 18, 2013, 06:55:24 AM »
The block is great, I love it .

A small request ...

  Smiley's are displayed as text rather then the smiley itself and also &nbsp

Missing something ?

Offline MissyNL

  • Jr. Member
  • **
  • Posts: 73
  • SMF Version: 2 RC4
  • SP Version: 2.3.3
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #130 on: February 21, 2013, 02:13:57 PM »
as many others... love the block :D

But after putting it online,  i noticed that my shoutbox did not work anymore. When i tried to delete the block or deactivate it i got this message: Session verification failed. Please try logging out and back in again, and then try again.

So.. i erased the php code... saved it and then was able to delete the block. very strange... has anyone also have this?


Have two suggestions though... is it possible to choose what boards to display? I have several categories in recent topics since my forum is quit large. So it would be very handy for me to choose what topics are displayd... also...

Is it possible to align the avatar in the top left with a small V & hspace? Now the avatar shows in the middle and it looks messy...

Also... Although i have selected to show the topics... it shows the RE: before it... can that also be deleted?
« Last Edit: February 21, 2013, 05:02:17 PM by MissyNL »

Offline thisizaremix

  • Just Registered
  • Posts: 1
  • SMF Version: 2.0.2
  • SP Version: 2.3.5
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #131 on: March 02, 2013, 03:48:35 AM »
After searching and searching for days and not finding a "Recent Posts" block that links to the beginning of a topic along with linking to the last post, I modified your code successfully to get it to do what I want.  I don't write code, I just try to modify it to get it to work the way I want.

It works perfectly but it still has a bunch of code that isn't necessary for what I am using it for.  Could you please help me clean it up to get rid of the stuff I am not using?

Here is a screenshot of how I am using this:


Code: [Select]
<?php

/*
Block: Recent posts with post preview
Author: Blue @ Simple Portal.net
Version: 1.6
*/

/* [SETUP WHAT YOU WANT HERE] */

$topics_posts 1; // TOPICS - 1 | MESSAGES - 2
$limit 10; // How many recent posts do you want to output?
$number 0; // How many characters do you want to output?
$exclude_boards null; // IF null guests can see all boards | IF you want to hide some boards use: array( ID1, ID2, ID3) where ID is the board's ID
$htmlspecialcharacters false// Do you need to show html special characters like Greek characters?

// Scroll Enable? Height and Speed?
$scrolling 0;       // ENABLE - 1 | DISABLE - 2
$speed 3;           // SLOW - 1 | MEDIUM - 10 | FAST - 20
$height "150px";
$scrollbar 0;       // ENABLE - 1 | DISABLE - 2

// Do you want to translate it to your own language? :P
$text['sportal_false'] = 'Simple Portal not found';
$text['board'] = 'in';
$text['who'] = 'by';

/* [STOP!] - THIS IS THE END OF SETUP */

//Only code from now on ;)
global $smcFunc$scripturl$sourcedir$modSettings$user_info$settings$context;

// Lets see if you are using Simple Portal. If not...well...go get them :D
if (!file_exists($sourcedir '/PortalBlocks.php'))
{
echo $text['sportal_false'];
return;
}

// Let's grab some database results
if ($topics_posts == 1) {

if (is_array($exclude_boards) || (int) $exclude_boards === $exclude_boards)
{
$exclude_boards is_array($exclude_boards) ? $exclude_boards : array($exclude_boards);
}
elseif ($exclude_boards != null)
{
$output_method $exclude_boards;
$exclude_boards = array();
}

$posts_result $smcFunc['db_query']('''
   SELECT m.poster_name, m.poster_time, m.id_msg, t.id_member_updated, m.subject, m.body, m.id_topic, b.name, t.id_last_msg, u.avatar, g.online_color,' 
. ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from'
) . '
   FROM {db_prefix}topics AS t
   LEFT JOIN {db_prefix}boards AS b ON (t.id_board = b.id_board)
   LEFT JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_last_msg)
   LEFT JOIN {db_prefix}members AS u ON (t.id_member_updated = u.id_member)
   LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
   ' 
. (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' 
$user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' 
$user_info['id'] . ')' '') . '     
   WHERE m.approved=1'   
. (empty($exclude_boards) ? '' '
AND b.id_board NOT IN ({array_int:exclude_boards})'
) . ' AND {query_see_board}
   ORDER BY t.id_last_msg DESC
   LIMIT ' 
$limit
array(
'exclude_boards' => empty($exclude_boards) ? '' $exclude_boards,
)   
   );
$posts = array();
while (
$row_posts $smcFunc['db_fetch_assoc']($posts_result))
{

      global 
$memberContext;
      
loadMemberData($row_posts['id_member_updated']);
      
loadMemberContext($row_posts['id_member_updated']);

   
$posts[] = array(
  'id' => $row_posts['id_member_updated'],
      
'username' => '<a style="color: ' $row_posts['online_color'] . ';" href="' $scripturl '?action=profile;u=' $row_posts['id_member_updated'] . '">' $row_posts['poster_name'] . '</a>',
      
'subject' => '<a style="font-weight: bold;" title="' $row_posts['subject'] . '" href="' $scripturl '?topic=' $row_posts['id_topic'] . ';topicseen#new">' $row_posts['subject'] . '</a>',
      
'subject2' => '<a style="color:red;"font-weight: bold;" title="Go to the last post" href="' $scripturl '?topic=' $row_posts['id_topic'] . '.msg' $row_posts['id_last_msg'] . ';topicseen#new">&#38;#9658;Last Post</a>',
      
'body' => $row_posts['body'],
  'avatar' => $row_posts['avatar'] == '' $memberContext[$row_posts['id_member_updated']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' $row_posts['avatar']),
  'board' => $row_posts['name'], 
  'time' => timeformat($row_posts['poster_time']),
  'new' => !empty($row_posts['is_read'])
   );
}
$smcFunc['db_free_result']($posts_result);

} else {

if (is_array($exclude_boards) || (int) $exclude_boards === $exclude_boards)
{
$exclude_boards is_array($exclude_boards) ? $exclude_boards : array($exclude_boards);
}
elseif ($exclude_boards != null)
{
$output_method $exclude_boards;
$exclude_boards = array();
}

$posts_result $smcFunc['db_query']('''
   SELECT m.poster_name, m.poster_time, m.id_msg, m.id_member, m.subject, m.body, m.id_topic, b.name, b.id_board, u.avatar, g.online_color,' 
. ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from'
) . '
   FROM {db_prefix}messages AS m
   LEFT JOIN {db_prefix}boards AS b ON (m.id_board = b.id_board)
   LEFT JOIN {db_prefix}members AS u ON (m.id_member = u.id_member)
   LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
   ' 
. (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' 
$user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' 
$user_info['id'] . ')' '') . '   
   WHERE m.approved=1'   
. (empty($exclude_boards) ? '' '
AND b.id_board NOT IN ({array_int:exclude_boards})'
) . ' AND {query_see_board}
   ORDER BY m.id_msg DESC
   LIMIT ' 
$limit
array(
'exclude_boards' => empty($exclude_boards) ? '' $exclude_boards,
)   
   );
$posts = array();
while (
$row_posts $smcFunc['db_fetch_assoc']($posts_result))
{

      global 
$memberContext;
      
loadMemberData($row_posts['id_member']);
      
loadMemberContext($row_posts['id_member']);

   
$posts[] = array(
  'id' => $row_posts['id_member'],
      
'username' => '<a style="color: ' $row_posts['online_color'] . ';" href="' $scripturl '?action=profile;u=' $row_posts['id_member'] . '">' $row_posts['poster_name'] . '</a>',
      
'subject' => '<a style="font-weight: bold;" title="' $text['board'] . '&nbsp;' $row_posts['name'] .'" href="' $scripturl '?topic=' $row_posts['id_topic'] . '.msg' $row_posts['id_msg'] . ';topicseen#new">' $row_posts['subject'] . '</a>',
      
'body' => $row_posts['body'],
  'avatar' => $row_posts['avatar'] == '' $memberContext[$row_posts['id_member']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' $row_posts['avatar']),
  'board' => $row_posts['name'],  
  'time' => timeformat($row_posts['poster_time']),
  'new' => !empty($row_posts['is_read'])
   );
}
$smcFunc['db_free_result']($posts_result);

}

//Finally the Output

//Scrolling xD
if ($scrolling == 1)
echo 
'<div style="overflow: hidden;"><marquee height=' $height ' behavior="scroll" direction="up" scrollamount="' $speed '" onmouseover="this.stop()" onmouseout="this.start()">';

if (
$scrollbar == 1)
echo 
'<div style="height:' $height '; overflow-y: scroll; overflow-x: hidden;">';

foreach (
$posts as $post) {

// Lets fix the BBCode bug and Strip the Text
$content1 str_replace("[""<"$post['body']);
$content2 str_replace("]"">"$content1); 
$content3 strip_tags($content2);
$preview substr ($content3,0,$number);

echo
'<table>
<tr>

<td>
str_ireplace('Re: '''$post['subject']);

if (!$post['new'] && $context['user']['is_logged'])
echo '&nbsp;<img src="'$settings['images_url'], '/'$context['user']['language'], '/new.gif" alt="new" border="0" />';

echo
'



<br /><small>' 
$post['subject2'];




echo '
$text['who'] . '&nbsp;' $post['username'] . '<br />' $post['time'] .'</small>
</td>
</tr>
</table>'
;

if ($htmlspecialcharacters) {
echo htmlspecialchars($previewENT_NOQUOTES"UTF-8") . '';
} else {
echo $preview '';
}

echo 
'<hr />';
}
        
//Scrolling xD
if ($scrollbar == 1)
echo 
'</div>'

if (
$scrolling == 1)
echo 
'</marquee></div>';
?>

Offline t-geronimo

  • Just Registered
  • Posts: 1
  • SMF Version: 2.0.2
  • SP Version: 2.3.5
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #132 on: March 17, 2013, 10:56:11 AM »
Hello!

I am new here and "search" did not help me.

Is there any way to exclude not only boards from the "Recent Topics/Posts"-block but also subboards?
Sorry if this was already asked and I did not find it.

Offline velorooms

  • Jr. Member
  • **
  • Posts: 83
    • Velorooms
  • SMF Version: 2.0.2
  • SP Version: 2.3.5
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #133 on: March 25, 2013, 05:31:10 PM »
Im wondering how easy it would be to work it so that it only pulls the latest posts from the topic it is in.

For instance, one block, but when displayed in board 72 it only pulls topics from board 72, etc

So it displays latest posts from the currently active board?
Admin and Owner of Velorooms.com - Using SMF 2.0.3 and Simpleportal 2.3.5

Offline Old Fossil

  • Beta Tester
  • *
  • Posts: 796
  • Gender: Male
  • SMF Version: 2.0.4
  • SP Version: 2.3.5
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #134 on: April 08, 2013, 10:06:17 PM »
Tried this on my forum.

However I am unable to hide more than one board despite having a few I want to remain hidden.

Any fix?

Have been seeing erors in my error log regarding this.

Use of undefined constant ID2 - assumed 'ID2'
« Last Edit: April 09, 2013, 04:56:06 PM by Old Fossil »
Daily backups mean less headaches

Block Set Up

I may be no coding expert but I am willing to help where I can.

I eat Spammers for breakfast

Offline Blue

  • Customizer
  • *
  • Posts: 379
  • Gender: Male
  • Block Maker? =P
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #135 on: April 27, 2013, 08:28:01 AM »
Hello!

I am new here and "search" did not help me.

Is there any way to exclude not only boards from the "Recent Topics/Posts"-block but also subboards?
Sorry if this was already asked and I did not find it.
Subboards have their own ID so just add it to the excluded_boards parameter :)
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Offline Blue

  • Customizer
  • *
  • Posts: 379
  • Gender: Male
  • Block Maker? =P
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #136 on: May 02, 2013, 08:22:03 PM »
Tried this on my forum.

However I am unable to hide more than one board despite having a few I want to remain hidden.

Any fix?

Have been seeing erors in my error log regarding this.

Use of undefined constant ID2 - assumed 'ID2'

Hum... it is working on my test forum. Can you please show me the code that you are using? I want to see the excluded_boards parameter

Im wondering how easy it would be to work it so that it only pulls the latest posts from the topic it is in.

For instance, one block, but when displayed in board 72 it only pulls topics from board 72, etc

So it displays latest posts from the currently active board?

It's a great idea, I'm going to look it it and add it in the next version :)
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Offline Old Fossil

  • Beta Tester
  • *
  • Posts: 796
  • Gender: Male
  • SMF Version: 2.0.4
  • SP Version: 2.3.5
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #137 on: May 02, 2013, 08:28:31 PM »
Code: [Select]
/*
Block: Recent posts with post preview
Author: Blue @ Simple Portal.net
Version: 1.6
*/

/* [SETUP WHAT YOU WANT HERE] */

$topics_posts = 1; // TOPICS - 1 | MESSAGES - 2
$limit = 10; // How many recent posts do you want to output?
$number = 70; // How many characters do you want to output?
$exclude_boards = ( 2 ); // IF null guests can see all boards | IF you want to hide some boards use: array( ID1, ID2, ID3) where ID is the board's ID
$htmlspecialcharacters = false; // Do you need to show html special characters like Greek characters?

// Scroll Enable? Height and Speed?
$scrolling =1;       // ENABLE - 1 | DISABLE - 2
$speed = 2;           // SLOW - 1 | MEDIUM - 10 | FAST - 20
$height = "200px";
$scrollbar = 0;       // ENABLE - 1 | DISABLE - 2

// Do you want to translate it to your own language? :P
$text['sportal_false'] = 'Simple Portal not found';
$text['board'] = 'in';
$text['who'] = 'by';

/* [STOP!] - THIS IS THE END OF SETUP */

//Only code from now on ;)
global $smcFunc, $scripturl, $sourcedir, $modSettings, $user_info, $settings, $context, $memberContext;

// Lets see if you are using Simple Portal. If not...well...go get them :D
if (!file_exists($sourcedir . '/PortalBlocks.php'))
{
echo $text['sportal_false'];
return;
}

// Let's grab some database results
if ($topics_posts == 1)
{

    if (is_array($exclude_boards) || (int) $exclude_boards === $exclude_boards)
    $exclude_boards = is_array($exclude_boards) ? $exclude_boards : array($exclude_boards);
    elseif ($exclude_boards != null)
    {
$output_method = $exclude_boards;
$exclude_boards = array();
    }

    $posts_result = $smcFunc['db_query']('', '
      SELECT m.poster_name, m.poster_time, m.id_msg, t.id_member_updated, m.subject, m.body, m.id_topic, b.name,
    t.id_last_msg, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . '
FROM {db_prefix}topics AS t
LEFT JOIN {db_prefix}boards AS b ON (t.id_board = b.id_board)
LEFT JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_last_msg)
LEFT JOIN {db_prefix}members AS u ON (t.id_member_updated = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '     
WHERE m.approved=1'   . (empty($exclude_boards) ? '' : ' AND m.poster_time > 0
AND b.id_board NOT IN ({array_int:exclude_boards})') . ' AND {query_see_board}
ORDER BY t.id_last_msg DESC
LIMIT ' . $limit,
array('exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards,)   
);
    $posts = array();
    while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
    {
loadMemberData($row_posts['id_member_updated']);
loadMemberContext($row_posts['id_member_updated']);

$posts[] = array(
    'id' => $row_posts['id_member_updated'],
    'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member_updated'] . '">' . $row_posts['poster_name'] . '</a>',
    'subject' => '<a style="font-weight: bold;" title="' . $text['board'] . '&nbsp;' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_last_msg'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
    'body' => $row_posts['body'],
    'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member_updated']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
    'board' => $row_posts['name'],
    'time' => timeformat($row_posts['poster_time']),
    'new' => !empty($row_posts['is_read'])
        );
    }
    $smcFunc['db_free_result']($posts_result);

}
else
{
    if (is_array($exclude_boards) || (int) $exclude_boards === $exclude_boards)
$exclude_boards = is_array($exclude_boards) ? $exclude_boards : array($exclude_boards);
    elseif ($exclude_boards != null)
    {
$output_method = $exclude_boards;
$exclude_boards = array();
    }

    $posts_result = $smcFunc['db_query']('', '
SELECT m.poster_name, m.poster_time, m.id_msg, m.id_member, m.subject, m.body, m.id_topic, b.name,
b.id_board, u.avatar, g.online_color,' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . '
FROM {db_prefix}messages AS m
LEFT JOIN {db_prefix}boards AS b ON (m.id_board = b.id_board)
LEFT JOIN {db_prefix}members AS u ON (m.id_member = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '   
WHERE m.approved=1'   . (empty($exclude_boards) ? '' : ' AND m.poster_time > 0
AND b.id_board NOT IN ({array_int:exclude_boards})') . ' AND {query_see_board}
ORDER BY m.id_msg DESC
LIMIT ' . $limit,
array('exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards,)   
    );
    $posts = array();
    while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
    {
loadMemberData($row_posts['id_member']);
loadMemberContext($row_posts['id_member']);

$posts[] = array(
    'id' => $row_posts['id_member'],
    'username' => '<a style="color: ' . $row_posts['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member'] . '">' . $row_posts['poster_name'] . '</a>',
    'subject' => '<a style="font-weight: bold;" title="' . $text['board'] . '&nbsp;' . $row_posts['name'] .'" href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_msg'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
    'body' => $row_posts['body'],
    'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
    'board' => $row_posts['name'], 
    'time' => timeformat($row_posts['poster_time']),
    'new' => !empty($row_posts['is_read'])
    );
    }
    $smcFunc['db_free_result']($posts_result);
}

//Finally the Output

//Scrolling xD
if ($scrolling == 1)
    echo '
    <marquee style="overflow:hidden;height:' . $height . ';" behavior="scroll" direction="up" scrollamount="' . $speed . '" onmouseover="this.stop()" onmouseout="this.start()">';

if ($scrollbar == 1 && !empty($posts))
    echo '
<div style="height:' . $height . '; overflow-y: scroll; overflow-x: hidden;">';

if (!empty($posts))
    echo '
    <table style="width:100%;">';
   
foreach ($posts as $post)
{
    if (empty($post['body']))
    {
echo '<tr><td>&nbsp</td></tr>';
exit;
    }
   
    // Lets fix the BBCode bug and Strip the Text
    $content1 = str_replace("[", "<", $post['body']);
    $content2 = str_replace("]", ">", $content1);
    $content3 = strip_tags($content2);
    $preview = substr($content3,0,$number);

    echo'    
<tr>
    <td style="width: 40px;">
<img src="' . $post['avatar'] .'" alt="" style="width:40px;height:40px;position:relative;top:10px;" />
    </td>
    <td>
' . $post['subject'];

    if (!$post['new'] && $context['user']['is_logged'])
echo '
&nbsp;<img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="new" border="0" />';

echo '
<br />
<span style="font-size:small;">' . $text['who'] . '&nbsp;' . $post['username'] . '&nbsp;|&nbsp;' . $post['time'] .'</span>
    </td>
</tr>
<tr>';

    if ($htmlspecialcharacters)
echo '
    <td style="border:0px;">&nbsp;</td>
    <td style="border:0px;">', htmlspecialchars($preview, ENT_NOQUOTES, "UTF-8") . '...', '</td>';
    else
echo '
    <td style="border:0px;">&nbsp;</td>
    <td style="border:0px;">', $preview . '...', '</td>';

    echo '
</tr>
<tr>
    <td colspan="2" style="border-top: thin dotted;height:0px;line-height:0px;padding:0%;display:hidden;width:100%;position:relative;">
<span></span>
    </td>
</tr>';
}

if (!empty($posts))
    echo '
    </table>';
   
//Scrolling xD
if ($scrollbar == 1 && !empty($posts))
    echo '
</div>';

if ($scrolling == 1)
    echo '
    </marquee>';

Here ya go Blue (or is it Purple?)

Anyways can ya show me where exactly the board numbers should go please bud.

Another thing I recently noticed.

Is there a way for the block to show the display name and not the name a person registered with?

Daily backups mean less headaches

Block Set Up

I may be no coding expert but I am willing to help where I can.

I eat Spammers for breakfast

Offline Mick.

  • Comrade
  • *
  • Posts: 77
  • Gender: Male
  • Premium SMF Themes
    • idesignSMF
  • SMF Version: 2.0.15
  • SP Version: 2.3.7
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #138 on: May 02, 2013, 11:29:22 PM »
Blue, if or when you update, remember img tags are shown in the preview as bbc. I think code tags too but I don't remember.

Offline Blue

  • Customizer
  • *
  • Posts: 379
  • Gender: Male
  • Block Maker? =P
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #139 on: May 04, 2013, 07:48:56 AM »
Here ya go Blue (or is it Purple?)

It is Blue but SiNaN prefers to call me Purple :dead: eheh!

Quote
Anyways can ya show me where exactly the board numbers should go please bud.

Another thing I recently noticed.

Is there a way for the block to show the display name and not the name a person registered with?

In the excluded parameter you forgot to add "array()". If you want to excluded more than one board you have to write "array( ID1, ID2, ID3)"

I have made the modifications so that it displays the real_name instead of poster_name :) try and see if everything is alright

Code: [Select]
<?php
/*
Block: Recent posts with post preview
Author: Blue @ Simple Portal.net
Version: 1.6
*/

/* [SETUP WHAT YOU WANT HERE] */

$topics_posts 1; // TOPICS - 1 | MESSAGES - 2
$limit 10; // How many recent posts do you want to output?
$number 70; // How many characters do you want to output?
$exclude_boards = array(2); // IF null guests can see all boards | IF you want to hide some boards use: array( ID1, ID2, ID3) where ID is the board's ID
$htmlspecialcharacters false// Do you need to show html special characters like Greek characters?

// Scroll Enable? Height and Speed?
$scrolling =1;       // ENABLE - 1 | DISABLE - 2
$speed 2;           // SLOW - 1 | MEDIUM - 10 | FAST - 20
$height "200px";
$scrollbar 0;       // ENABLE - 1 | DISABLE - 2

// Do you want to translate it to your own language? :P
$text['sportal_false'] = 'Simple Portal not found';
$text['board'] = 'in';
$text['who'] = 'by';

/* [STOP!] - THIS IS THE END OF SETUP */

//Only code from now on ;)
global $smcFunc$scripturl$sourcedir$modSettings$user_info$settings$context$memberContext;

// Lets see if you are using Simple Portal. If not...well...go get them :D
if (!file_exists($sourcedir '/PortalBlocks.php'))
{
echo $text['sportal_false'];
return;
}

// Let's grab some database results
if ($topics_posts == 1)
{

    if (
is_array($exclude_boards) || (int) $exclude_boards === $exclude_boards)
    
$exclude_boards is_array($exclude_boards) ? $exclude_boards : array($exclude_boards);
    elseif (
$exclude_boards != null)
    {
$output_method $exclude_boards;
$exclude_boards = array();
    }

    
$posts_result $smcFunc['db_query']('''
      SELECT u.real_name, m.poster_time, m.id_msg, t.id_member_updated, m.subject, m.body, m.id_topic, b.name,
    t.id_last_msg, u.avatar, g.online_color,' 
. ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from'
) . '
FROM {db_prefix}topics AS t
LEFT JOIN {db_prefix}boards AS b ON (t.id_board = b.id_board)
LEFT JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_last_msg)
LEFT JOIN {db_prefix}members AS u ON (t.id_member_updated = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
. (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' 
$user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' 
$user_info['id'] . ')' '') . '     
WHERE m.approved=1'   
. (empty($exclude_boards) ? '' ' AND m.poster_time > 0
AND b.id_board NOT IN ({array_int:exclude_boards})'
) . ' AND {query_see_board}
ORDER BY t.id_last_msg DESC
LIMIT ' 
$limit
array('exclude_boards' => empty($exclude_boards) ? '' $exclude_boards,)   
);
    
$posts = array();
    while (
$row_posts $smcFunc['db_fetch_assoc']($posts_result))
    {

loadMemberData($row_posts['id_member_updated']);
loadMemberContext($row_posts['id_member_updated']);

$posts[] = array(
    'id' => $row_posts['id_member_updated'],
    'username' => '<a style="color: ' $row_posts['online_color'] . ';" href="' $scripturl '?action=profile;u=' $row_posts['id_member_updated'] . '">' $row_posts['real_name'] . '</a>',
    'subject' => '<a style="font-weight: bold;" title="' $text['board'] . '&nbsp;' $row_posts['name'] .'" href="' $scripturl '?topic=' $row_posts['id_topic'] . '.msg' $row_posts['id_last_msg'] . ';topicseen#new">' $row_posts['subject'] . '</a>',
    'body' => $row_posts['body'],
    'avatar' => $row_posts['avatar'] == '' $memberContext[$row_posts['id_member_updated']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' $row_posts['avatar']),
    'board' => $row_posts['name'], 
    'time' => timeformat($row_posts['poster_time']),
    'new' => !empty($row_posts['is_read'])
    
    );
    }
    
$smcFunc['db_free_result']($posts_result);

}
else
{
    if (
is_array($exclude_boards) || (int) $exclude_boards === $exclude_boards)
$exclude_boards is_array($exclude_boards) ? $exclude_boards : array($exclude_boards);
    elseif (
$exclude_boards != null)
    {
$output_method $exclude_boards;
$exclude_boards = array();
    }

    
$posts_result $smcFunc['db_query']('''
SELECT u.real_name, m.poster_time, m.id_msg, m.id_member, m.subject, m.body, m.id_topic, b.name,
b.id_board, u.avatar, g.online_color,' 
. ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from'
) . '
FROM {db_prefix}messages AS m
LEFT JOIN {db_prefix}boards AS b ON (m.id_board = b.id_board)
LEFT JOIN {db_prefix}members AS u ON (m.id_member = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
. (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' 
$user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' 
$user_info['id'] . ')' '') . '   
WHERE m.approved=1'   
. (empty($exclude_boards) ? '' ' AND m.poster_time > 0
AND b.id_board NOT IN ({array_int:exclude_boards})'
) . ' AND {query_see_board}
ORDER BY m.id_msg DESC
LIMIT ' 
$limit
array('exclude_boards' => empty($exclude_boards) ? '' $exclude_boards,)   
    );
    
$posts = array();
    while (
$row_posts $smcFunc['db_fetch_assoc']($posts_result))
    {

loadMemberData($row_posts['id_member']);
loadMemberContext($row_posts['id_member']);

$posts[] = array(
    'id' => $row_posts['id_member'],
    'username' => '<a style="color: ' $row_posts['online_color'] . ';" href="' $scripturl '?action=profile;u=' $row_posts['id_member'] . '">' $row_posts['real_name'] . '</a>',
    'subject' => '<a style="font-weight: bold;" title="' $text['board'] . '&nbsp;' $row_posts['name'] .'" href="' $scripturl '?topic=' $row_posts['id_topic'] . '.msg' $row_posts['id_msg'] . ';topicseen#new">' $row_posts['subject'] . '</a>',
    'body' => $row_posts['body'],
    'avatar' => $row_posts['avatar'] == '' $memberContext[$row_posts['id_member']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' $row_posts['avatar']),
    'board' => $row_posts['name'],  
    'time' => timeformat($row_posts['poster_time']),
    'new' => !empty($row_posts['is_read'])
    );
    }
    
$smcFunc['db_free_result']($posts_result);
}

//Finally the Output

//Scrolling xD
if ($scrolling == 1)
    echo 
'
    <marquee style="overflow:hidden;height:' 
$height ';" behavior="scroll" direction="up" scrollamount="' $speed '" onmouseover="this.stop()" onmouseout="this.start()">';

if (
$scrollbar == && !empty($posts))
    echo 
'
<div style="height:' 
$height '; overflow-y: scroll; overflow-x: hidden;">';

if (!empty(
$posts))
    echo 
'
    <table style="width:100%;">'
;
    
foreach (
$posts as $post)
{
    if (empty(
$post['body']))
    {
echo '<tr><td>&nbsp</td></tr>';
exit;
    }
    
    
// Lets fix the BBCode bug and Strip the Text
    
$content1 str_replace("[""<"$post['body']);
    
$content2 str_replace("]"">"$content1); 
    
$content3 strip_tags($content2);
    
$preview substr($content3,0,$number);

    echo
'     
<tr>
    <td style="width: 40px;">
<img src="' 
$post['avatar'] .'" alt="" style="width:40px;height:40px;position:relative;top:10px;" />
    </td>
    <td>
$post['subject'];

    if (!
$post['new'] && $context['user']['is_logged'])
echo '
&nbsp;<img src="'
$settings['images_url'], '/'$context['user']['language'], '/new.gif" alt="new" border="0" />';

echo '
<br />
<span style="font-size:small;">' 
$text['who'] . '&nbsp;' $post['username'] . '&nbsp;|&nbsp;' $post['time'] .'</span>
    </td>
</tr>
<tr>'
;

    if (
$htmlspecialcharacters
echo '
    <td style="border:0px;">&nbsp;</td>
    <td style="border:0px;">'
htmlspecialchars($previewENT_NOQUOTES"UTF-8") . '...''</td>';
    else 
echo '
    <td style="border:0px;">&nbsp;</td>
    <td style="border:0px;">'
$preview '...''</td>';

    echo 
'
</tr>
<tr>
    <td colspan="2" style="border-top: thin dotted;height:0px;line-height:0px;padding:0%;display:hidden;width:100%;position:relative;">
<span></span>
    </td>
</tr>'
;
}

if (!empty(
$posts))
    echo 
'
    </table>'
;
    
//Scrolling xD
if ($scrollbar == && !empty($posts))
    echo 
'
</div>'


if (
$scrolling == 1)
    echo 
'
    </marquee>'
;

Blue, if or when you update, remember img tags are shown in the preview as bbc. I think code tags too but I don't remember.

Thank you for the heads up. I'll fix it in the next version :)
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.