Simple Machines Community Forum

Customizing SMF => Tips and Tricks => Topic started by: rocknroller on August 16, 2011, 05:31:02 PM

Title: Here is php code for Recent Topic with avatar and popup preview
Post by: rocknroller on August 16, 2011, 05:31:02 PM
Quotehere is php code for php block, you can easy use it with portals.  :)

..::Recent Topic with avatar and popup preview::..




/**
* @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">
          <tr>
              <td>', $txt['replies'], '</td>
              <td colspan="4"></td>
          </tr>';
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 class="side_class_poster"><pre> ', $post['poster']['link'], ' </pre> </td>
    </tr>
        <tr>
            <td colspan="6"><hr /></td>
        </tr>';
}
echo '
    </table>
<style type="text/css">
.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>';



Enjoy!

thx to blue for avatar.

Added
Title: Re: Here is php code for Recent Topic with avatar and popup preview
Post by: darren1981 on August 16, 2011, 10:44:16 PM
Thanks... but it's not working for me:

QuoteParse error: syntax error, unexpected '<' in

added it as a php block and i am getting the above error.
Title: Re: Here is php code for Recent Topic with avatar and popup preview
Post by: Hj Ahmad Rasyid Hj Ismail on August 17, 2011, 03:21:44 AM
Interesting... How would it looks when being used? Any pictures/images?
Title: Re: Here is php code for Recent Topic with avatar and popup preview
Post by: rocknroller on August 17, 2011, 10:42:47 AM
Quote from: darren1981 on August 16, 2011, 10:44:16 PM
Thanks... but it's not working for me:

QuoteParse error: syntax error, unexpected '<' in

added it as a php block and i am getting the above error.

Which of portal you are using on your forum?

Quote from: ahrasis on August 17, 2011, 03:22:44 AM
Interesting... How would it looks when being used? Any pictures/images?
looks different on each theme:

(http://www.pohrani.com/f/o/uN/3XpylBV/pr.png)

demo is available here (http://www.logooff.net/index.php) in left column.
Title: Re: Here is php code for Recent Topic with avatar and popup preview
Post by: darren1981 on August 18, 2011, 01:43:21 AM
This looks awesome.. would also love to add it to my forum... i am using "PortaMX" as my portal as it best suits my requirements for now.. i played around with it for about 15mins and still couldn't get it to work.. just kept showing that error.

Your site / Demo looks great by the way... Cheers for any help on this.

Regards, Darren
Title: Re: Here is php code for Recent Topic with avatar and popup preview
Post by: rocknroller on August 18, 2011, 11:35:38 AM
Quote from: darren1981 on August 18, 2011, 01:43:21 AM
This looks awesome.. would also love to add it to my forum... i am using "PortaMX" as my portal as it best suits my requirements for now.. i played around with it for about 15mins and still couldn't get it to work.. just kept showing that error.

Your site / Demo looks great by the way... Cheers for any help on this.

Regards, Darren

try now! it should be works!
Title: Re: Here is php code for Recent Topic with avatar and popup preview
Post by: darren1981 on August 18, 2011, 11:49:19 PM
Thanks Bud :)

Working a treat now, cheers for that.. i did try to resolve / modify it myself but with little luck :(
Title: Re: Here is php code for Recent Topic with avatar and popup preview
Post by: rocknroller on August 19, 2011, 08:30:50 AM
Quote from: darren1981 on August 18, 2011, 11:49:19 PM
Thanks Bud :)

Working a treat now, cheers for that.. i did try to resolve / modify it myself but with little luck :(

no problem,  :) enjoy.

I will add more setup functions very soon.
Title: Re: Here is php code for Recent Topic with avatar and popup preview
Post by: teos55 on November 21, 2011, 11:59:14 AM
   Great tip, thanks.  Is there a way to make the block scrollable ? I want to see 20 recent topics but takes to much space on the screen.