collapse

* User Info

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

* Who's Online

  • Dot Guests: 73
  • Dot Hidden: 0
  • Dot Users: 1
  • Dot 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

NEED HELP? If you're looking for support with Simple Portal, look no further than the Support Board!

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

0 Members and 1 Guest are viewing this topic.

Offline Doctor Deejay

  • Localizer
  • Language
  • *
  • Posts: 825
  • Gender: Male
  • SMF Version: 2.0.2
  • SP Version: 2.3.5
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #100 on: May 31, 2012, 03:54:37 PM »
You're welcome, glad to help :)
Doctor Deejay
Simple Portal - Language Team
SMF - Localizer
Vienara - Lead Developer

Backup both your files and database before modifying anything!

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, 05:39:58 AM »
I want to not to show context. How can I do it ?

Offline phantomm

  • Support
  • *
  • Posts: 379
  • Gender: Male
  • Smile, tomorrow will be worse...
    • Polish ElkArte community
  • SMF Version: 2.0.2
  • SP Version: 2.3.5
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #102 on: July 28, 2012, 05: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, 06: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

  • Support
  • *
  • Posts: 379
  • Gender: Male
  • Smile, tomorrow will be worse...
    • Polish ElkArte community
  • SMF Version: 2.0.2
  • SP Version: 2.3.5
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #104 on: July 28, 2012, 06: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, 06: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, 07: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, 07:23:51 AM by Atletico »

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 #107 on: August 08, 2012, 10:37:02 AM »
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, 06: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, 04: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: 74
    • 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, 08: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 XaR

  • 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, 05: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, 10: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: 378
  • Gender: Male
  • Block Maker? =P
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #112 on: November 11, 2012, 12: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, 09: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: 29
  • SMF Version: 2 RC5
  • SP Version: 2.3.3
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #114 on: November 16, 2012, 03:51:15 AM »
Fantastic thanks for this

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


Offline Blue

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

Correct...

:)

Thank you sir!