TinyPortal

Development => Block Codes => Topic started by: WarBirD on December 07, 2006, 01:05:44 PM

Title: How to put latest Forum posts in a Centerblock ?
Post by: WarBirD on December 07, 2006, 01:05:44 PM
Hi, how can I put the latest Forumposts into a centerblock ? So I can put it above the articles on the main site.
Thx.

WarBirD
Title: Re: How to put latest Forum posts in a Centerblock ?
Post by: Lesmond on December 07, 2006, 05:10:47 PM
try this in a php block

// "Recent Topics" a php Block
// Prefered settings when being designed
// Border and title on
// Title ="Recent Topics"

global $scripturl;
$what=ssi_recentTopics('10', NULL, 'array');

echo '<table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">';
echo '<tr class="catbg3"><td valign="middle" align="center">Subject</td><td valign="middle" align="center">Board</td><td valign="middle" align="center">Poster</td><td valign="middle" align="center">Time</td></tr>';

foreach ($what as $topic)
  {
    echo '<tr><td class="windowbg" valign="middle" align="center">', $topic['link'];
    // Is this topic new? (assuming they are logged in!)
    if (!$topic['new'] && $context['user']['is_logged'])
      echo '<a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['time'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';
      echo '</td><td class="windowbg2" valign="middle" align="center">', $topic['board']['link'], '</td>';
      echo '</td><td class="windowbg2" valign="middle" align="center">', $topic['poster']['link'], '</td><td class="windowbg2" valign="middle" align="center">';
      if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
      echo '<a href="', $topic['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: right;" /></a>';
      echo '<span class="smalltext">', $topic['time'], '</span></td></tr>';
  }

echo '</table>';
Title: Re: How to put latest Forum posts in a Centerblock ?
Post by: WarBirD on December 07, 2006, 06:56:33 PM
Thx m8. ;)
Title: Re: How to put latest Forum posts in a Centerblock ?
Post by: Lesmond on December 07, 2006, 07:26:00 PM
your welcome :)
Title: Re: How to put latest Forum posts in a Centerblock ?
Post by: WarBirD on December 07, 2006, 07:28:13 PM
But, the text in the block is aligned centered. can this be changed, that its aligned left like the usual of a forum ? Looks stupid centered. ;)
Any ideas how to change that ?
Title: Re: How to put latest Forum posts in a Centerblock ?
Post by: rebelrose on December 07, 2006, 07:55:55 PM
Try this one


// "Recent Topics" a php Block
// Prefered settings when being designed
// Border and title on
// Title ="Recent Topics"

global $scripturl;
$what=ssi_recentTopics('10', NULL, 'array');

echo '<table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">';
echo '<tr class="catbg3"><td valign="middle" align="left">Subject</td><td valign="middle" align="left">Board</td><td valign="middle" align="left">Poster</td><td valign="middle" align="left">Time</td></tr>';

foreach ($what as $topic)
  {
    echo '<tr><td class="windowbg" valign="middle" align="left">', $topic['link'];
    // Is this topic new? (assuming they are logged in!)
    if (!$topic['new'] && $context['user']['is_logged'])
      echo '<a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['time'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';
      echo '</td><td class="windowbg2" valign="middle" align="left">', $topic['board']['link'], '</td>';
      echo '</td><td class="windowbg2" valign="middle" align="left">', $topic['poster']['link'], '</td><td class="windowbg2" valign="middle" align="left">';
      if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
      echo '<a href="', $topic['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: right;" /></a>';
      echo '<span class="smalltext">', $topic['time'], '</span></td></tr>';
  }

echo '</table>';
Title: Re: How to put latest Forum posts in a Centerblock ?
Post by: Lesmond on December 07, 2006, 07:57:29 PM
Was just going to post that RebelRose :)
Title: Re: How to put latest Forum posts in a Centerblock ?
Post by: rebelrose on December 07, 2006, 07:58:45 PM
Quote from: Lesmond on December 07, 2006, 07:57:29 PM
Was just going to post that RebelRose :)

Sorry didn't mean to get in your way :)

If mine is not correct then you give it a go ;)
Title: Re: How to put latest Forum posts in a Centerblock ?
Post by: Lesmond on December 07, 2006, 08:04:48 PM
its ok RebelRose, its the same thanks :)
Title: Re: How to put latest Forum posts in a Centerblock ?
Post by: WarBirD on December 07, 2006, 08:22:17 PM
Thx again. ;) Both of you.
Title: Re: How to put latest Forum posts in a Centerblock ?
Post by: rebelrose on December 07, 2006, 08:33:36 PM
Your most welcome, from both of us  :laugh:
Title: Re: How to put latest Forum posts in a Centerblock ?
Post by: SRaven on December 07, 2006, 09:08:20 PM
If you want the actual recent posts and not just the topics
Then just add this to a phpbox center block:

ssi_recentPosts();

Title: Re: How to put latest Forum posts in a Centerblock ?
Post by: The_Unknown on July 11, 2008, 11:54:03 AM
Hi,

I want to show only forum topics created by admins/moderators and not by members in the front page, although the respective board allows regular members to post also.

Is there a way to use this center block script to do it? Or some other solution?
Title: Re: How to put latest Forum posts in a Centerblock ?
Post by: IchBin on July 11, 2008, 02:03:25 PM
Could you Please read the Posting Guidelines (http://www.tinyportal.net/index.php?topic=581) and start your own topic. Thanks.