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

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

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

0 Members and 5 Guests are viewing this topic.

Offline Kryzen

  • Localizer
  • Language
  • *
  • Posts: 826
  • Gender: Male
  • SMF Version: 2.0.11
  • SP Version: 2.3.6
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #100 on: May 31, 2012, 05:54:37 PM »
You're welcome, glad to help :)

Offline Atletico

  • Semi Newbie
  • *
  • Posts: 12
  • SMF Version: 2.0.2
  • SP Version: 2.3.5
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #101 on: July 28, 2012, 07:39:58 AM »
I want to not to show context. How can I do it ?

Offline phantomm

  • Translator
  • *
  • Posts: 406
  • Gender: Male
  • Smile, tomorrow will be worse...
    • Polish ElkArte community
  • SMF Version: None
  • Elkarte Version: 1.0.5
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #102 on: July 28, 2012, 07:55:15 AM »
you mean message content?

Offline Atletico

  • Semi Newbie
  • *
  • Posts: 12
  • SMF Version: 2.0.2
  • SP Version: 2.3.5
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #103 on: July 28, 2012, 08:05:07 AM »
Yes, because, pictures and videos are not be shown and it looks bad.

For example, "http://www.bilim.org/wp-content/uploads/su_basinc.jpgSizce donarken ge..."

Offline phantomm

  • Translator
  • *
  • Posts: 406
  • Gender: Male
  • Smile, tomorrow will be worse...
    • Polish ElkArte community
  • SMF Version: None
  • Elkarte Version: 1.0.5
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #104 on: July 28, 2012, 08:17:07 AM »
Find:
Code: [Select]
if ($htmlspecialcharacters) {
echo htmlspecialchars($preview, ENT_NOQUOTES, "UTF-8") . '...';
} else {
echo $preview . '...';
}

Replace with:
Code: [Select]
//if ($htmlspecialcharacters) {
//echo htmlspecialchars($preview, ENT_NOQUOTES, "UTF-8") . '...';
//} else {
//echo $preview . '...';
//}

Offline Atletico

  • Semi Newbie
  • *
  • Posts: 12
  • SMF Version: 2.0.2
  • SP Version: 2.3.5
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #105 on: July 28, 2012, 08:26:16 AM »
Thanks :)

Offline Atletico

  • Semi Newbie
  • *
  • Posts: 12
  • SMF Version: 2.0.2
  • SP Version: 2.3.5
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #106 on: July 28, 2012, 09:01:09 AM »
Another question;

I deleted marquee and I want to use <hr /> code. But, it should not be shown aftr last line. How can I do it ?

Code: [Select]
<?php

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

/* [SETUP WHAT YOU WANT HERE] */

$topics_posts 1; // TOPICS - 1 | MESSAGES - 2
$limit 5; // How many recent posts do you want to output?
$number 70; // 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 1;       // ENABLE - 1 | DISABLE - 2
$height "250px";
$speed 3;           // SLOW - 1 | MEDIUM - 10 | FAST - 20

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

/* [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="' $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 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;">';

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 style="width: 40px; height: 40px;" >
<img src="' 
$post['avatar'] .'" alt="" width="30px" height="30px" />
</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 />
<small>' 
$text['who'] . '&nbsp;' $post['username'] . '&nbsp;|&nbsp;' $post['time'] .'</small>
</td>
</tr>
</table>'
;

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

echo '';
}

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

And I want to resize avatars; not 30px height and weight.
« Last Edit: July 28, 2012, 09:23:51 AM by Atletico »

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 #107 on: August 08, 2012, 12:37:02 PM »
Thanks for this block.I was a little changed.I want to show the first pictures in this block.How can I do it ? Thanks.



Code: [Select]
<?php

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

/* [SETUP WHAT YOU WANT HERE] */

$topics_posts 2;  // TOPICS - 1 | MESSAGES - 2
$limit 20;  // How many recent posts do you want to output?
$number 0;  // How many characters do you want to output?
$exclude_boards = array(318427426432425433424,423431434430,429);  // 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 =true// Do you need to show html special characters like Greek characters?
$default_avatar 'http://img15.hostingpics.net/pics/282198defaultavatar.png';

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

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

/* [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="' $text['board'] . ' ' $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 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'] . ' ' $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()">';

foreach (
$posts as $post) {

// Lets fix the BBCode bug and Strip the Text
 
$form_message preg_replace(array('~\n?\[quote.*?\].*\[/quote\]\n?~is''~^\n~''~\[/quote\]~'), ''$post['body']);
$content1 str_replace("[""<"$form_message);
$content2 str_replace("]"">"$content1); 
$content3 strip_tags($content2);
$preview strip_tags(substr (htmlspecialchars_decode($content3),0,$number));

echo
'
<div class="mansetdeneme" width="width: 220px;" align="left">
<table>
 <tr>
 <td style="width: 40px;">'
;
               if (!empty(
$post['avatar'])){
echo'
<div class="manseta"> 
<img src="' 
$post['avatar'] .'" alt="" width="40px" height="24px" /></div>';

else {
echo '
<div class="manseta">
<img src="' 
$default_avatar .'" alt="" width="40px" height="24px" /></div>';
}
echo 
' </td>
       <td>
 ' 
str_ireplace('Re: '''$post['subject']);

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

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



echo 
'</div><br />';
 }

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

portal.css;

Code: [Select]
.mansetdeneme
{
    align: left;
   border: 1px solid #5998A7;
   border-radius: 3px;
   -moz-border-radius: 3px;
   -webkit-border-radius: 3px;
  padding: 3px 5px 7px 5px;  ;  ĂĽst saÄź alt Sol
}
.manseta
{
   align: left;
   border: 1px solid #5998A7;
   border-radius: 3px;
   -moz-border-radius: 3px;
   -webkit-border-radius: 3px;
  padding: 3px 5px 7px 5px;  ;  ĂĽst saÄź alt Sol
margin-top: 0px;
}
.mansetg
{
width: 20px;
height: 20px;
}

« Last Edit: August 09, 2012, 08:01:55 AM by kimyaci »
SMF 2.0.7 HabboArtv1, Default Themes.

Offline boo2

  • Semi Newbie
  • *
  • Posts: 34
  • SMF Version: 2.0.2
  • SP Version: 2.3.5
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #108 on: September 19, 2012, 06:21:25 PM »
Not sure anyone has noticed this but I opened my home page and found the this block wider than it should have been, by almost twice. So I noted the very lost post I mad and I had instructions inside the [ code ] tags, and when i opened that post and removed the code tags the block went back to it's normal size. How odd. Can anyone tell me if this code is causing that?

Must be because when I remove the code tags from that post all was well again.

I wonder if it's possible to have all urls and video urls removed so that they don't make the block look messy when you have the post content in view? I'd hate to miss out on the preview of the comments in the post but the urls look awful in the block.

Here's the code I am using with some modifications to it i found in this thread.
Code: [Select]
<?php

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

/* [SETUP WHAT YOU WANT HERE] */

$topics_posts 1; // TOPICS - 1 | MESSAGES - 2
$limit 15; // How many recent posts do you want to output?
$number 140; // How many characters do you want to output?
$exclude_boards = array( 12); // 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
$default_avatar 'http://cafewe.com/Themes/default/images/default_avatar.png';
$htmlspecialcharacters false// Do you need to show html special characters like Greek characters?

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

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

/* [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(ID20ID21ID22ID23ID24ID25);
}

$posts_result $smcFunc['db_query']('''
   SELECT IFNULL(u.real_name, m.poster_name) AS 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="' $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 IFNULL(u.real_name, m.poster_name) AS 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()">';

foreach (
$posts as $post) {

// Lets fix the BBCode bug and Strip the Text
$form_message preg_replace(array('~\n?\[quote.*?\].*\[/quote\]\n?~is''~^\n~''~\[/quote\]~'), ''$post['body']);
$content1 str_replace("[""<"$form_message);
$content2 str_replace("]"">"$content1); 
$content3 strip_tags($content2);
$preview strip_tags(substr (htmlspecialchars_decode($content3),0,$number));

echo
'<table>
<tr>'
;
if (!(empty(
$post['avatar'])))
echo
'    <td style="width: 40px;">';

if (!empty($post['avatar'])){
echo '<img src="' $post['avatar'] .'" alt="" width="40px" height="40px" />';
} else {
echo '<img src="' $default_avatar .'" alt="" width="40px" height="40px" />';
}
echo '  </td><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>' 
$text['who'] . '&nbsp;' $post['username'] . '&nbsp;|&nbsp;' $post['time'] .'</small>
</td>
</tr>
</table>'
;

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

echo 
'<hr />';
}

//Scrolling xD
if ($scrolling == 1)
echo 
'</marquee></div>';
?>
Using SMF 2.0.2 and Simple portal 2.3.5

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 #109 on: October 07, 2012, 10:37:29 AM »
is it possible to edit it so that when scrolling and it reaches the bottom the new posts it doesnt insert the whitespace so that there is a constant flow of posts rather than a gap between last and first?
Admin and Owner of Velorooms.com - Using SMF 2.0.3 and Simpleportal 2.3.5

Offline Xarwin

  • Semi Newbie
  • *
  • Posts: 12
  • SMF Version: 2.0.8
  • SP Version: 2.3.5
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #110 on: November 04, 2012, 06:40:04 PM »
I just wanted to thank you for this amazing piece of coding.
Works flawlessly.

Offline kachan64

  • Semi Newbie
  • *
  • Posts: 16
  • Gender: Male
    • Chat 'n' Go
  • SMF Version: 2.0.1
  • SP Version: 2.3.4
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #111 on: November 09, 2012, 11:43:05 PM »
Got so much boards.
How can I exclude them easily?  :0
I stepped on a cornflake, does this make me a serial killer?

Offline Blue

  • Customizer
  • *
  • Posts: 379
  • Gender: Male
  • Block Maker? =P
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #112 on: November 11, 2012, 01:42:01 PM »
Got so much boards.
How can I exclude them easily?  :0

You can exclude some boards changing the value

Code: [Select]
$exclude_boards = null;
See the info in the first post ;)

I just wanted to thank you for this amazing piece of coding.
Works flawlessly.

Thank you :D :D
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 #113 on: November 14, 2012, 10:46:03 AM »
Looking at the screenshot below...

How do I make the "box" for Recent Topics a specific size ... like when set for scrolling... yet NOT scroll... but rather have a slider?

Thanks!


Offline Tricky

  • Semi Newbie
  • *
  • Posts: 27
  • SMF Version: 2 RC5
  • SP Version: 2.3.3
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #114 on: November 16, 2012, 04:51:15 AM »
Fantastic thanks for this

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 #115 on: November 18, 2012, 05:37:32 PM »
Thanks for this block


Offline Blue

  • Customizer
  • *
  • Posts: 379
  • Gender: Male
  • Block Maker? =P
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #116 on: November 19, 2012, 02:44:27 PM »
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 #117 on: November 19, 2012, 07:33:57 PM »
Looking at the screenshot below...

How do I make the "box" for Recent Topics a specific size ... like when set for scrolling... yet NOT scroll... but rather have a slider?

Thanks!

Still wondering how I can make it stop scrolling ... but include a scroll bar instead?

Thanks!

Offline Blue

  • Customizer
  • *
  • Posts: 379
  • Gender: Male
  • Block Maker? =P
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #118 on: November 24, 2012, 08:09:09 PM »
Hum... Scroll bar, no auto scrolling right? :) I'll code it for you tomorrow
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 #119 on: November 24, 2012, 10:02:13 PM »
Hum... Scroll bar, no auto scrolling right? :) I'll code it for you tomorrow

Correct...

:)

Thank you sir!