TinyPortal

Development => Block Codes => Topic started by: tattooedpierre on November 12, 2005, 11:01:44 AM

Title: Scrolling Recent Posts
Post by: tattooedpierre on November 12, 2005, 11:01:44 AM
Ok, I grabbed this code block from the official SMF forums:


// Show lots of posts.
if (!empty($context['latest_posts']))
{
echo '<marqueeÂÃ,  behavior="scroll" direction="up" height="50" scrolldelay="300" scrollamount="2">
<table width="100%" border="0">';
/* Each post in latest_posts has:
board (with an id, name, and link.), topic (the topic's id.), poster (with id, name, and link.),
subject, short_subject (shortened with...), time, link, and href. */
foreach ($context['latest_posts'] as $post)
echo '
<tr>
<td align="right" valign="top" nowrap="nowrap">[', $post['board']['link'], ']</td>
<td valign="top">', $post['link'], ' ', $txt[525], ' ', $post['poster']['link'], '</td>
<td align="right" valign="top" nowrap="nowrap">', $post['time'], '</td>
</tr>';
echo '
</table></marquee>';
}


.. now normally this would go in your index.template.php below template_menu(); .. A better way I had hoped would be to add this as a PHP block.. but when I do this I get a blank area (either as a block or in index.template.php). No errors, just no recent posts either :S .. can anyone help?

Here's the original offical SMF board link http://www.simplemachines.org/community/index.php?topic=13985.0 (http://www.simplemachines.org/community/index.php?topic=13985.0)

EDIT: To clarify, the purpose is to allow my recent posts to scroll, allowing me to show more than say 5 at a time; whilst maintaining the block size.
Title: Re: Scrolling Recent Posts
Post by: bloc on November 13, 2005, 09:55:19 AM
Thats a bit of code that assume its variable being pre-filled in BoardIndex.php - where it fetch and call another routine from Recent.php.

So no, it won't display anything  - unless its placed in BoardIndex.template which its normally located (not in index.template.php).
Title: Re: Scrolling Recent Posts
Post by: tattooedpierre on November 13, 2005, 10:15:42 AM
Excellent Bloc, cheers.. ok. so in TP it now shows the recent posts which is excellent.. but they're not moving! Any ideas?
Title: Re: Scrolling Recent Posts
Post by: bloc on November 13, 2005, 10:26:13 AM
Hm..some javascript code to make it move within a div perhaps...I am not sure what exists of such though.
Title: Re: Scrolling Recent Posts
Post by: tattooedpierre on November 13, 2005, 10:26:59 AM
Quote from: Bloc on November 13, 2005, 10:26:13 AM
Hm..some javascript code to make it move within a div perhaps...I am not sure what exists of such though.

Ah I see.. not to worry then ;)
Title: Re: Scrolling Recent Posts
Post by: Nokonium on November 13, 2005, 10:51:40 AM
The display of recent shouts scrolls, could that code be transplanted?
Title: Re: Scrolling Recent Posts
Post by: tattooedpierre on November 13, 2005, 01:18:26 PM
Quote from: nokonium on November 13, 2005, 10:51:40 AM
The display of recent shouts scrolls, could that code be transplanted?

It does?! Mines doenst :(
Title: Re: Scrolling Recent Posts
Post by: Nokonium on November 13, 2005, 06:19:41 PM
Not automatically, but it has a scrollbar. Though you can get a scrolling shout box

http://www.totaltwaddle.co.uk/board/

This is based on the Classic theme, but it is SMF
Title: Re: Scrolling Recent Posts
Post by: snork13 on November 13, 2005, 06:33:44 PM
well, i don't know how bloc feels about messing with his code...but i get it to scroll without a problem...$Themes/TPortalBlocks.template

change this:

// TPortal shoutbox
function TPortal_shoutbox()
{
ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  global $context, $settings, $options, $scripturl, $txt, $modSettings;

ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  // Show the shoutbox, takes settings from tpadmin
ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ, if(isset($context['TPortal']['querystring']))
ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ, $tp_where=$context['TPortal']['querystring'];
ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ, else
ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  $tp_where='';

ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ, if(!isset($context['TPortal']['shoutbox']))
ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ, $context['TPortal']['shoutbox']='';

ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ, echo ' <table style="table-layout: fixed;" cellpadding="0" height="'.$context['TPortal']['shoutbox_height'].'" cellspacing="0" border="0" width="100%"><tr><td class="smalltext"><div style="height: '.$context['TPortal']['shoutbox_height'].'px; overflow: auto; width: 100%;">', $context['TPortal']['shoutbox'], '
ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ, </div></td></tr></table><form style="margin-top: 8px; text-align: center;" class="smalltext" name="tp-shoutbox" action="'.$scripturl.'?action=tpmod&id=shout" method="post">
ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ, ';
ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ, if(($context['TPortal']['guest_shout']) || (!$context['TPortal']['guest_shout'] && !$context['user']['is_guest']))
ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ, echo '<textarea class="smalltext" name="tp-shout" style="width: 80%; height: 50px;" type="text"></textarea><br /><input style="margin-top: 4px;" class="smalltext" type="submit" name="shout_send" value="'.$txt['shout!'].'">';

ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ, if($context['user']['is_guest'] && $context['TPortal']['guest_shout'])
ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ, echo '<br /><input style="margin-top: 4px;" size="20" class="smalltext" type="text" name="tp-shout-name" value="'.$txt['tp-guest'].'">';
ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ, else
ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ, echo '<input type="hidden" name="tp-shout-name" value="'.$context['user']['name'].'">';

ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ, echo '<input name="tp-shout-url" type="hidden" value="'.$tp_where.'">
ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ, </form>';
}



to this:

// TPortal shoutbox
function TPortal_shoutbox()
{
ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  global $context, $settings, $options, $scripturl, $txt, $modSettings;

ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  // Show the shoutbox, takes settings from tpadmin
ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ, if(isset($context['TPortal']['querystring']))
ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ, $tp_where=$context['TPortal']['querystring'];
ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ, else
ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  $tp_where='';

ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ, if(!isset($context['TPortal']['shoutbox']))
ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ, $context['TPortal']['shoutbox']='';

ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ, echo ' <marqueeÂÃ,  behavior="scroll" direction="up" height="100" scrolldelay="300" scrollamount="2" onmouseover="this.stop()" onmouseout="this.start()"><table style="table-layout: fixed;" cellpadding="0" height="'.$context['TPortal']['shoutbox_height'].'" cellspacing="0" border="0" width="100%"><tr><td class="smalltext"><div style="height: '.$context['TPortal']['shoutbox_height'].'px; width: 100%;">', $context['TPortal']['shoutbox'], '
ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ, </div></td></tr></table></marquee><form style="margin-top: 8px; text-align: center;" class="smalltext" name="tp-shoutbox" action="'.$scripturl.'?action=tpmod&id=shout" method="post">
ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ, ';
ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ, if(($context['TPortal']['guest_shout']) || (!$context['TPortal']['guest_shout'] && !$context['user']['is_guest']))
ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ, echo '<textarea class="smalltext" name="tp-shout" style="width: 80%; height: 50px;" type="text"></textarea><br /><input style="margin-top: 4px;" class="smalltext" type="submit" name="shout_send" value="'.$txt['shout!'].'">';

ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ, if($context['user']['is_guest'] && $context['TPortal']['guest_shout'])
ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ, echo '<br /><input style="margin-top: 4px;" size="20" class="smalltext" type="text" name="tp-shout-name" value="'.$txt['tp-guest'].'">';
ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ, else
ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ, echo '<input type="hidden" name="tp-shout-name" value="'.$context['user']['name'].'">';

ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ, echo '<input name="tp-shout-url" type="hidden" value="'.$tp_where.'">
ÂÃ,  ÂÃ,  ÂÃ,  ÂÃ, </form>';
}


hopeÂÃ,  this is ok and helps

ps <marquee> is sloppy fix ;)
Title: Re: Scrolling Recent Posts
Post by: tattooedpierre on November 13, 2005, 07:44:52 PM
I dont appear to have the TPortalBlocks.template file in my black22 directory (which is my default theme) .. should this be there? It is in my netpune theme folder though?

EDIT: I just added into Neptune to see if it works, and it does. So if this could be modified for recent posts, this would be most excellent!
Title: Re: Scrolling Recent Posts
Post by: IchBin on November 13, 2005, 11:17:41 PM
TPortalBlocks.template should be located in the SMF default theme.
Title: Re: Scrolling Recent Posts
Post by: Teknomancer on December 04, 2005, 05:27:04 AM
I've got scrolling to work flawlessly!!

Here's what to do

REPLACE

echo '<table style="table-layout: fixed;" cellpadding="0" height="'.$context['TPortal']['shoutbox_height'].'" cellspacing="0" border="0" width="100%"><tr><td class="smalltext"><div style="height: '.$context['TPortal']['shoutbox_height'].'px; overflow: auto; width: 100%;">', $context['TPortal']['shoutbox'], '
       </div></td></tr></table><form style="margin-top: 8px; text-align: center;" class="smalltext" name="tp-shoutbox" action="'.$scripturl.'?action=tpmod&id=shout" method="post">
       ';


WITH


echo ' <marquee  behavior="scroll" direction="up" height='.$context['TPortal']['shoutbox_height'].'px scrolldelay=" 10" scrollamount=" 1" onmouseover="this.stop()" onmouseout="this.start()"><table style="table-layout: fixed;" cellpadding="0" height="'.$context['TPortal']['shoutbox_height'].'" cellspacing="0" border="0" width="100%"><tr><td class="smalltext"><div style="height: '.$context['TPortal']['shoutbox_height'].'px; width: 100%;">', $context['TPortal']['shoutbox'], '
       </div></td></tr></table></marquee><form style="margin-top: 8px; text-align: center;" class="smalltext" name="tp-shoutbox" action="'.$scripturl.'?action=tpmod&id=shout" method="post">
       ';


Oh it's ALMOST the same as snork13's idea but only extra thing is instead of hardcoding 100 has height of shoutbox, it takes it from the Admin panel settings of the shoutbox.

Cool!
Title: Re: Scrolling Recent Posts
Post by: tattooedpierre on December 04, 2005, 03:35:52 PM
Excellent I got this to work great for the shoutbox.. for the recent topics though... ? any ideas?
Title: Re: Scrolling Recent Posts
Post by: houston on December 06, 2005, 06:14:49 PM
Mine is running somewhat jerky. Although I do have a few gifs running in the forum as well.

Thanks anyways for the code.
Title: Re: Scrolling Recent Posts
Post by: MetalHellsangel on February 24, 2006, 05:27:56 AM
If anyone is interested I found a way to scroll posts Look at THIS TOPIC (http://www.tinyportal.net/index.php?topic=3007.msg25121#msg25121)
Title: Re: Scrolling Recent Posts
Post by: Reko on March 16, 2008, 10:07:41 PM
that like to scrolling potss isnt valid anymore
Title: Re: Scrolling Recent Posts
Post by: IchBin on March 17, 2008, 01:43:09 PM
Should work now.