SimplePortal

Customization => Blocks and Modifications => Block Requests => Topic started by: rocknroller on June 25, 2011, 04:20:49 AM

Title: Recent topic with popup
Post by: rocknroller on June 25, 2011, 04:20:49 AM
..::Recent Topic with avatar and popup preview::..
Verson 1.2


Code: [Select]
/**
 * Recent Topic with avatar and popup preview
 * Version 1.2
 * @author logooff.net
 */
 
//SETUP

$number_of_posts =10; // here you can change number of posts
$default_avatar = 'http://www.pohrani.com/f/45/mu/1bzggGqq/noavatar.png'; // enter URL of default avatar you want. Like this 'http://www.url.com/image.jpg'

//SETUP END
global $contex, $txt, $settings;
$array = ssi_recentTopics($number_of_posts, null, null, 'array');
echo '
<table class="side_class_row">';
foreach ($array as $post)
{
global $memberContext;
      loadMemberData($post['poster']['id']);
      loadMemberContext($post['poster']['id']);
echo '
  <tr>
<td class="side_class_replies">', $post['replies'], '</td>
            <td  class="side_class_new">';
                if (!empty($post['new']) )
                    echo'';
                else
                    echo'
                    <img src="' . $settings['lang_images_url'] . '/new.gif" class="new_posts" alt="new" />';
             echo'
            </td>
            <td></td>
    <td><div class="triangle-isosceles" id="a', $post['topic'], '" style="display: none">', $post['preview'], '</div>
                    <a href="'. $post['href']. '" target="_self" onmouseover="document.getElementById(\'a', $post['topic'], '\').style.display = \'block\'" onmouseout="document.getElementById(\'a', $post['topic'], '\').style.display = \'none\'">', $post['short_subject'], '</a>
             </td>
<td>';
            if (!empty($memberContext[$post['poster']['id']]['avatar']['href'])){
echo '<img src="' . $memberContext[$post['poster']['id']]['avatar']['href'] . '" width="30" height="30" alt="', $post['poster']['name'], '" />';
                    }           
            else {
echo '<img src="' . $default_avatar .'" alt="default_avatar" width="30" height="30" />';
                }
        echo'
            </td>
            <td></td>
    </tr>
        <tr>
            <td colspan="6"><p class="side_class_poster"><span class="floatleft">', $txt['replies'], '</span> ', $post['poster']['link'], ' </p><hr class="side_hr" /></td>
        </tr>';
}
echo '
    </table>
<style type="text/css">
.side_class_poster
{
     font-size:10px;
     margin: 0;
     padding: 0;
     text-align: right;
}
table.side_class_row hr
     margin: 0;
     padding: 0;
}
.side_class_row
{
     padding:4px;
     width: 100%;
}
td.side_class_replies
{
     text-align:center;
     width:3%;
}
td.side_class_new
{
     text-align:center;
     width:3%;
}
.triangle-isosceles {
    position: fixed;
    top: 300px;
    left: 400px;
    padding:15px;
    margin:1em 0 3em;
    color:#fff;
    max-width: 400px;
    border: 1px solid #222222;
    -moz-border-radius:10px;
    -webkit-border-radius:10px;
    border-radius:10px;
    -moz-box-shadow: 3px 3px 39px 2px #222222;
    -webkit-box-shadow: 3px 3px 39px 2px #222222;
    box-shadow: 3px 3px 39px 2px #222222;
    background: -moz-linear-gradient(top, rgba(41,137,216,0.9) 0%, rgba(30,87,153,0.9) 94%, rgba(30,87,153,0.9) 100%);
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(41,137,216,0.9)), color-stop(94%,rgba(30,87,153,0.9)), color-stop(100%,rgba(30,87,153,0.9)));
    background: -webkit-linear-gradient(top, rgba(41,137,216,0.9) 0%,rgba(30,87,153,0.9) 94%,rgba(30,87,153,0.9) 100%);
    background: -o-linear-gradient(top, rgba(41,137,216,0.9) 0%,rgba(30,87,153,0.9) 94%,rgba(30,87,153,0.9) 100%);
    background: -ms-linear-gradient(top, rgba(41,137,216,0.9) 0%,rgba(30,87,153,0.9) 94%,rgba(30,87,153,0.9) 100%);
    background: linear-gradient(top, rgba(41,137,216,0.9) 0%,rgba(30,87,153,0.9) 94%,rgba(30,87,153,0.9) 100%);
    }
</style>';
Enjoy!


29.08.2011
Version 1.2


16.07.2011
Title: Re: Recent topic with popup
Post by: Blue on July 03, 2011, 09:59:47 AM
Here, try this:

Code: [Select]
<?php

$array 
ssi_recentTopics(10nullnull'array');
global 
$contex$txt$settings;
echo 
'
<table class="side_class_row">
        <thead>
            <tr>
                <td>'
$txt['replies'], '</td>
                <td></td>
                <td></td>
<td></td>
                <td></td>
            </tr>
        <thead>'
;
foreach (
$array as $post)
{

global $memberContext;
      
loadMemberData($post['poster']['id']);
      
loadMemberContext($post['poster']['id']);


echo 
'
        <tbody>
  <tr>
<td class="side_class_replies">'
$post['replies'], '</td>
            <td  class="side_class_new">'
;
                if (!empty(
$post['new']) )
                    echo
'';
                else
                    echo
'
                    <img src="' 
$settings['lang_images_url'] . '/new.gif" class="new_posts" alt="" />';
             echo
'
                </td>
                <td></td>
     <td>
                    <div class="triangle-isosceles" id="'
$post['topic'], '" style="display: none">'$post['preview'], '</div>
                    <a href="'
$post['href']. '" target="_self" onmouseover="document.getElementById(\''$post['topic'], '\').style.display = \'block\'" onmouseout="document.getElementById(\''$post['topic'], '\').style.display = \'none\'">'$post['short_subject'], '</a>
                </td>
<td><img src="' 
$memberContext[$post['poster']['id']]['avatar']['href'] . '" width="30px" height="30px" /></td>
                <td class="side_class_poster"><pre> '
$post['poster']['name'], ' </pre> </td>
     </tr>
            <tr>
                <td colspan="5"><hr></td>
            </tr>
        </tbody>'
;
}
echo 
'
    </table> 
<style> 
.side_class_poster pre
{
     font-size:10px;
}
.side_class_row
{
     padding:4px;
     width: 100%;
}
td.side_class_replies
{
     text-align:center;
     width:3%;
}
td.side_class_new
{
     text-align:center;
     width:3%;
}
.triangle-isosceles {
    position: fixed;
    top: 300px;
    left: 400px;
    padding:15px;
    margin:1em 0 3em;
    color:#fff;
    max-width: 400px;
    border: 1px solid #222222;
    -moz-border-radius:10px;
    -webkit-border-radius:10px;
    border-radius:10px;
    -moz-box-shadow: 3px 3px 39px 2px #222222;
    -webkit-box-shadow: 3px 3px 39px 2px #222222;
    box-shadow: 3px 3px 39px 2px #222222;
    background: -moz-linear-gradient(top, rgba(41,137,216,0.9) 0%, rgba(30,87,153,0.9) 94%, rgba(30,87,153,0.9) 100%);
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(41,137,216,0.9)), color-stop(94%,rgba(30,87,153,0.9)), color-stop(100%,rgba(30,87,153,0.9)));
    background: -webkit-linear-gradient(top, rgba(41,137,216,0.9) 0%,rgba(30,87,153,0.9) 94%,rgba(30,87,153,0.9) 100%);
    background: -o-linear-gradient(top, rgba(41,137,216,0.9) 0%,rgba(30,87,153,0.9) 94%,rgba(30,87,153,0.9) 100%);
    background: -ms-linear-gradient(top, rgba(41,137,216,0.9) 0%,rgba(30,87,153,0.9) 94%,rgba(30,87,153,0.9) 100%);
    background: linear-gradient(top, rgba(41,137,216,0.9) 0%,rgba(30,87,153,0.9) 94%,rgba(30,87,153,0.9) 100%);
    }
</style>'
;

?>
Title: Re: Recent topic with popup
Post by: agent47 on July 03, 2011, 11:19:48 AM
Wow this looks so awesome.... I wish someone would implement this for this mod (http://simpleportal.net/index.php?topic=1621.0). It'll look so awesome.
Title: Re: Recent topic with popup
Post by: Blue on July 03, 2011, 11:32:40 AM
I have to re-do that block since that was my first block ever  ;P

Maybe, when I start I'll ask rocknroller if I can use his code.
Title: Re: Recent topic with popup
Post by: rocknroller on July 03, 2011, 11:44:25 AM
I have to re-do that block since that was my first block ever  ;P

Maybe, when I start I'll ask rocknroller if I can use his code.

tnx friend for avatar, sure you can use it. I'm glad that someone like this code.  :D
Title: Re: Recent topic with popup
Post by: Blue on July 03, 2011, 12:01:39 PM
Glad I could help ;)
Title: Re: Recent topic with popup
Post by: agent47 on July 03, 2011, 12:07:23 PM
You guys rule!
Title: Re: Recent topic with popup
Post by: S@ffz on August 11, 2011, 09:26:28 PM
I have to re-do that block since that was my first block ever  ;P

Maybe, when I start I'll ask rocknroller if I can use his code.

Are you still going too Blue?
 is it possible to reduce the amount of topics displayed?
Title: Re: Recent topic with popup
Post by: rocknroller on August 16, 2011, 05:18:41 PM
I have to re-do that block since that was my first block ever  ;P

Maybe, when I start I'll ask rocknroller if I can use his code.

Are you still going too Blue?
is it possible to reduce the amount of topics displayed?

Edited first post.. :)
Title: Re: Recent topic with popup
Post by: S@ffz on August 28, 2011, 05:59:00 PM
Thanks rocknroller

One more Question how can I tidy the contents displayed in the block as they are very space apart and almost looks
bare.   As you can see from the attached image 5 post are displayed and there is a scroll bar at the bottom.   :(
and I don't know how or where to tidy this block.  Any help would be much appreciated.
Title: Re: Recent topic with popup
Post by: rocknroller on August 29, 2011, 11:24:31 AM
Thanks rocknroller

One more Question how can I tidy the contents displayed in the block as they are very space apart and almost looks
bare.   As you can see from the attached image 5 post are displayed and there is a scroll bar at the bottom.   :(
and I don't know how or where to tidy this block.  Any help would be much appreciated.

i was changed code in first post today with newer version, first change the code and is still have problem send me link of your forum, so can check with firebug. :)
Title: Re: Recent topic with popup
Post by: S@ffz on October 19, 2011, 05:14:27 AM
Great block guys

thanks  ;D
Title: Re: Recent topic with popup
Post by: FrizzleFried on April 04, 2012, 02:41:50 AM
Was wondering if there is a way to limit the forums this block looks for... I have a NSFW forum i want it to ignore.
Title: Re: Recent topic with popup
Post by: fapencio on April 04, 2014, 10:26:04 PM
awesome! thanks  :thumbsup: :applause:
Title: Re: Recent topic with popup
Post by: Schnuffeltier on April 06, 2014, 01:48:53 PM
Wow! This is really fantastic! I like the popups very much!

Would it be possible to add the popups to this code?

Code: [Select]
global $context, $settings, $scripturl, $txt;
global $user_info, $modSettings, $smcFunc, $posts;
global $color_profile;

$exclude_boards = null;
$num_recent = !empty($parameters[0]) ? $parameters[0] :  (isset($_GET['limit']) ? (int) $_GET['limit'] : 20);

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

$stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
$icon_sources = array();
foreach ($stable_icons as $icon)
$icon_sources[$icon] = 'images_url';

// Find all the posts in distinct topics.  Newer ones will have higher IDs.
$request = $smcFunc['db_query']('','
SELECT
m.poster_time, ms.subject, m.id_topic, m.id_member, m.id_msg, b.id_board, t.num_replies, t.num_views, b.name AS bName,
IFNULL(mem.real_name, m.poster_name) AS poster_name, ' . ($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') . ', LEFT(m.body, 384) AS body, m.smileys_enabled, mf.icon
FROM ({db_prefix}messages AS m, {db_prefix}topics AS t, {db_prefix}boards AS b, {db_prefix}messages AS ms)
INNER JOIN {db_prefix}messages AS mf ON (mf.id_msg = t.id_first_msg)
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = t.id_topic AND lt.id_member = {int:id_member})
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = {int:id_member})' : '') . '
WHERE t.ID_LAST_MSG >= ' . ($modSettings['maxMsgID'] - 35 * min($num_recent, 5)) . '
AND t.id_last_msg = m.id_msg
AND b.id_board = t.id_board' . (empty($exclude_boards) ? '' : '
AND b.id_board NOT IN ({array_int:exclude_boards})'). '
AND {raw:query_see_board}
AND ms.id_msg = t.id_last_msg
ORDER BY t.id_last_msg DESC
LIMIT {int:limit}',
array(
'id_member' => $user_info['id'],
'exclude_boards' => $exclude_boards,
'query_see_board' => $user_info['query_wanna_see_board'],
'limit' => (int) $num_recent,
)
);
$posts = array();
$colorids = array();
while ($row = $smcFunc['db_fetch_assoc']($request))
{
$row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), array('<br />' => '')));
if ($smcFunc['strlen']($row['body']) > 128)
$row['body'] = $smcFunc['substr']($row['body'], 0, 128) . '...';

// Censor the subject.
                  $row['subject'] = preg_replace('/^' . preg_quote($txt['response_prefix']) . '/', '', $row['subject']);
censorText($row['subject']);
censorText($row['body']);

//Collect the color ids :)
$colorids[$row['id_member']] = $row['id_member'];

if (empty($modSettings['messageIconChecks_disable']) && !isset($icon_sources[$row['icon']]))
$icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.gif') ? 'images_url' : 'default_images_url';

// Build the array.
$posts[] = array(
'board' => array(
'id' => $row['id_board'],
'name' => $row['bName'],
'href' => $scripturl . '?board=' . $row['id_board'] . '.0',
'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['bName'] . '</a>'
),
'topic' => $row['id_topic'],
'poster' => array(
'id' => $row['id_member'],
'name' => $row['poster_name'],
'href' => empty($row['id_member']) ? '' : $scripturl . '?action=profile;u=' . $row['id_member'],
'link' => empty($row['id_member']) ? $row['poster_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['poster_name'] . '</a>'
),
'subject' => $row['subject'],
'short_subject' => shorten_subject($row['subject'], 25),
'preview' => $row['body'],
'time' => timeformat($row['poster_time']),
'timestamp' => forum_time(true, $row['poster_time']),
'href' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . ';topicseen#new',
'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#new">' . $row['subject'] . '</a>',
'new' => !empty($row['is_read']),
'new_from' => $row['new_from'],
'icon' => '<img src="' . $settings[$icon_sources[$row['icon']]] . '/post/' . $row['icon'] . '.gif" align="middle" alt="' . $row['icon'] . '" border="0" />',
'views' => $row['num_views'],
'replies' => $row['num_replies'],
);
}
$smcFunc['db_free_result']($request);

// Load recent topic posts colors =)
if(!empty($colorids) && sp_loadColors($colorids) !== false)
foreach($posts as $k => $p)
if(!empty($color_profile[$p['poster']['id']]['link']))
$posts[$k]['poster']['link'] = $color_profile[$p['poster']['id']]['link'];

$context['recent_topics']=$posts;

// Just return it.
if (empty($posts))
return $posts;

echo '
<div class="tborder">
<table cellspacing="0" width="100%">
<tr class="catbg">

</tr>
<tr>
<td style="padding: 5px;">
</td> ';
foreach ($posts as $post)
echo '
<tr>
<td align="center" valign="middle" nowrap="nowrap">
', $post['icon'], '
</td>
<td valign="middle" width="%100">
<div style="font-size: 11px;"><b>
<a href="', $post['href'], '">', $post['subject'], '</a>
', $post['new'] ? '' : '<a href="' . $scripturl . '?topic=' . $post['topic'] . '.msg' . $post['new_from'] . ';topicseen#new"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $txt['new'] . '" border="0" /></a>', '</b></div><div style="font-size: 9px;">von ', $post['poster']['link'], ' in ', $post['board']['link'], ' </br> ', $post['time'], '

| Klicks: ', $post['views'], ' | Antworten: ', $post['replies'], '</font><hr>
</td>
</tr>';
echo '
</table></div>';

SimplePortal 2.3.8 © 2008-2024, SimplePortal