Recent Topic with more details on top

Started by yocks, January 11, 2012, 02:01:21 PM

Previous topic - Next topic

yocks

Hi php gurus,

Please help me or throw me your codings on how to display the 'recent topics' on top of the community forum. I need in the format shown below,



| Subject| Board Name| Posted By| No. of Replies| No. of Views| Date&Time |

Most importantly, the same topic should not be shown more than once in recent topic list. Only the most recent post  from the board should be display, whether its a new thread or post that doesn't matter.

In SMF at present it displays a topic more than once and not all the details as I mentioned above. Also it was shown at the bottom of the community forum.

Thank you Guys, I am running 2.0.2.

Just a code is enough for me to put in portamx block.



Tomy Tran

I just have quick view and believe you must dig in Sources/Subs-Recent.php to find out more. You must put more condition in querying database to get No. of Replies & Views and push it into $context['latest_posts'] on BoardIndex:


// Show lots of posts.
elseif (!empty($context['latest_posts']))
{
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 ($context['latest_posts'] as $post)
echo '
<dt><strong>', $post['link'], '</strong> ', $txt['by'], ' ', $post['poster']['link'], ' (', $post['board']['link'], ')</dt>
<dd>', $post['time'], '</dd>';
echo '
</dl>';
}


then you will have format for your style:

echo '| ', $post['link'], ' | ', $post['board']['link'], ' | ', $post['poster']['link'], ' | ', $post['replies']['link'], ' | ', $post['views']['link'], ' | ', $post['time'], ' |';

The variables is what you need code more on Sub Recent file.

yocks

Hi Tomy, thanks for your reply and for your code.

I am not very much aware of php coding and smf functionality, this was my first try to launch my forum. Can you please elaborate in a more Lehman way step by step, to put this code where and in which file. And the below coding where I have to place and in which file ?

echo '| ', $post['link'], ' | ', $post['board']['link'], ' | ', $post['poster']['link'], ' | ', $post['replies']['link'], ' | ', $post['views']['link'], ' | ', $post['time'], ' |';[/code/


Another thing, I am using portamx portal. Is there anyway, to retrieve the information from smf and display the recent topic wherever I need using a single php block in portamx, without touching the smf files ?

Tomy Tran

I dont use Portamx so I can not tell you exactly which file in your portal.

As normal forum, show information on forum's home page will be call on this file: /Themes/default/BoardIndex.template.php

For Recent Posts you are focused, it call function and query database on file of /Sources/Subs-Recent.php

For more detail on change, it's better for you to make a question where you get that Portal, they will have support topics and they may help if that portal is free open source.

Advertisement: