How to add recent posts from infocenter below Display.template.php?

Started by Moodx, November 19, 2010, 06:24:37 PM

Previous topic - Next topic

Moodx

Hi all!

I'm using default Theme on 2.0RC4.
I am trying to get a number of recent posts below a topic in Display.template.php.
I've added:

require("..../public_html/SSI.php");
ssi_recentPosts($num_recent = 15, $exclude_boards = null, $include_boards = null, $output_method = 'echo', $limit_body = true);

Those two lines to my Display.template.php, that works but it does't give me the nice look like in info center recent posts on frontpage,..
Also fiddled around with // This is the "Recent Posts" bar in Boardindex.template and copied that part to my display.template but no succes.

What to do to get the recent posts part (from the infocenter on frontpage) in Display.template?

Thanks for any support,..

IchBin™

You're better of doing it the SSI.php way. You just need to customize the output of the function. Changing the output method to array allows you to do just that. Then just use the same HTML from the boardindex.template file with a little modification.

$recentPosts = ssi_recentPosts($num_recent = 15, $exclude_boards = null, $include_boards = null, $output_method = 'array', $limit_body = true);

echo '
<dl id="ic_recentposts" class="middletext">';

/* 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 ($recentPosts as $post)
echo '
<dt><strong>', $post['link'], '</strong> ', $txt['by'], ' ', $post['poster']['link'], ' (', $post['board']['link'], ')</dt>
<dd>', $post['time'], '</dd>';
echo '
</dl>';
IchBin™        TinyPortal

Biology Forums

IchBin™, how do you configure this so that it only shows the LATEST post from each topic, as opposed to showing all the recent posts within that topic?

IchBin™

You completely rewrite the way the function works. Off the top of my head it wouldn't be easy.
IchBin™        TinyPortal

Biology Forums

Then how would you add a table around?

echo '
<dl id="ic_recentposts" class="middletext">';

/* 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 ($recentPosts as $post)
echo '
<dt><strong>', $post['link'], '</strong> ', $txt['by'], ' ', $post['poster']['link'], ' (', $post['board']['link'], ')</dt>
<dd>', $post['time'], '</dd>';
echo '
</dl>';


Currently it looks like this:

http://biology-forums.com/index.php/topic,1374.0.html

Biology Forums

Okay, I got it to work :)

<?php
// Version: 1.1; Display

function template_main()
{
global $context, $settings, $options, $txt, $scripturl, $modSettings;

$recentPosts = ssi_recentPosts($num_recent = 4, $exclude_boards = null, $include_boards = null,

$output_method = 'array', $limit_body = true);

echo
'
<table border="0" cellspacing="1" align="right" cellpadding="4" class="bordercolor" style="empty-

cells: show; background-color: rgb(99, 148, 189); "><tr><td align="center" style="color: rgb(255, 255,

255); font-size: 9pt; font-family: verdana; font-weight: bold; font-style: normal; background-color:

rgb(110, 148, 183); ">
Please Help Answer These Questions</td>
</tr>
<tr>
<td class="catbg" style="color: rgb(0, 0, 0); font-size: 9pt; font-family: verdana;

font-weight: bold; background-color: rgb(175, 198, 219); background-image: url(http://biology-

forums.com/Themes/classic/images/catbg.gif);">
Recently Updated Topics</td>
</tr>
<tr><td class="windowbg2" style="color: rgb(0, 0, 0); font-size: 9pt; font-family: verdana;

background-color: rgb(248, 248, 248); ">
<dl id="ic_recentposts" class="smalltext">'
;

/* 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 ($recentPosts as $post)
echo '
<dt><strong>'
, $post['link'], '</strong> ', $txt['by'], ' ', $post['poster']['link'], ' (',

$post['board']['link'], ')</dt>
<dd>'
, $post['time'], '</dd>';
echo
'
</dl>
</td></tr></table>'
;

//Display ads on the thread page


Good Luck Yall...

If you want the recent topics, just change ssi_recentPosts into ssi_recentTopics :)

IchBin™

Well there's a difference between the most recent post in a topic and recent topic, just to be clear. :) Glad you figured it out though.
IchBin™        TinyPortal

Advertisement: