collapse

* User Info

 
 
Welcome, Guest. Please login or register.
Did you miss your activation email?

* Who's Online

  • Dot Guests: 62
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

* Shoutbox

Refresh History
  • Shoutbox is not for support!
  • Mstcool: Oh, ok, Sinan
    August 25, 2014, 10:19:15 PM
  • ArsenArsen: When i make them
    August 19, 2014, 12:20:20 AM
  • ArsenArsen: I had some mod ideas, i will put them.
    August 19, 2014, 12:19:45 AM
  • [SiNaN]: We could, but it's there as a reminder of some kind, that we should fill it in, somehow.
    August 18, 2014, 09:57:14 PM
  • Mstcool: Y don't u guys remove the customization section since it has no files?
    August 17, 2014, 10:27:28 PM
  • ArsenArsen: Ok, Great!
    August 15, 2014, 03:13:18 PM
  • [SiNaN]: We have the translators' names listed in the downloads area.
    August 15, 2014, 03:05:39 PM
  • ArsenArsen: Never Mind, i wont, noone did.
    August 15, 2014, 02:22:32 PM
  • ArsenArsen: Can i put mz name on translation
    August 15, 2014, 02:21:06 PM
  • [SiNaN]: You can only change your forum profile options once you have 5 posts. I have made an exception for Translator group though, so you should be able to do it now.
    August 13, 2014, 03:32:17 PM
  • ArsenArsen: Cant find where to change avatar
    August 13, 2014, 03:12:38 PM
  • ArsenArsen: Ok
    August 11, 2014, 05:17:55 AM
  • Underdog: there is a documentation link on your top-right
    August 10, 2014, 08:48:45 PM
  • ArsenArsen: What to use for docs? This is NoT SP support question.
    August 10, 2014, 02:55:55 PM
  • Ron-KK4HGY: Hello all!
    August 06, 2014, 03:22:50 PM
  • USFA: tada
    August 04, 2014, 09:49:45 PM
  • BCNPalomino: lol, that search doe :O
    July 18, 2014, 09:26:27 AM
  • RohailPro23: hi all
    July 18, 2014, 08:09:00 AM
  • samborabora: sorry, thought this was search, lol
    June 29, 2014, 04:45:12 AM
  • samborabora: sp_embed_image
    June 29, 2014, 04:45:01 AM

* Team Blog

* Recent Posts

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: [Block] Recent Topics/Posts with Post Preview!  (Read 43312 times)

0 Members and 1 Guest are viewing this topic.

Offline Blue

  • Customizer
  • *
  • Posts: 378
  • Gender: Male
  • Block Maker? =P
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #120 on: November 25, 2012, 07: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, 12:52:39 PM »
Thank you!


Offline Blue

  • Customizer
  • *
  • Posts: 378
  • Gender: Male
  • Block Maker? =P
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #122 on: November 26, 2012, 05: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: 63
  • 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 18, 2012, 11:17:21 PM »
A very very nice mod.

Offline Mick.

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

Offline Mick.

  • Comrade
  • *
  • Posts: 81
  • Gender: Male
  • Premium SMF Themes
    • idesign360
  • SMF Version: 2.0.4
  • SP Version: 2.3.5
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #125 on: January 01, 2013, 10: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: 126
  • 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, 07: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://club-dhayzone.net/
    • 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, 09:25:26 AM »
I'm playing a little
but how would it?





Offline Blue

  • Customizer
  • *
  • Posts: 378
  • Gender: Male
  • Block Maker? =P
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #128 on: January 13, 2013, 08: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, 05: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, 01: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, 04:02:17 PM by MissyNL »

Offline thisizaremix

  • Newbie
  • 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, 02: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

  • Newbie
  • 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, 08: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: 74
    • 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, 03: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: 865
  • 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, 08: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, 02: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: 378
  • Gender: Male
  • Block Maker? =P
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #135 on: April 27, 2013, 06: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: 378
  • Gender: Male
  • Block Maker? =P
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #136 on: May 02, 2013, 06: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: 865
  • 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, 06: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: 81
  • Gender: Male
  • Premium SMF Themes
    • idesign360
  • SMF Version: 2.0.4
  • SP Version: 2.3.5
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #138 on: May 02, 2013, 09: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: 378
  • Gender: Male
  • Block Maker? =P
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #139 on: May 04, 2013, 05: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.