TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
Stats
  • Total Posts: 196,004
  • Total Topics: 21,330
  • Online today: 500
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 112
  • Total: 112

Recent Topics

Started by heusdens, January 04, 2008, 06:09:57 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

heusdens

Hi

I just installed Tinyportal and it's great.  Exactly what I was looking for.  Now I would like a customised Recent topics block but having a bit of difficulty.  Basically I only want to show last 20 topic names and nothing else.  for e.g I don't want it to show who posted it and there should not be a date.  How would I go about doing that?  Please help.

Ken.

Did you take a look at the Snippets Index to see if any of those would fit your needs?
" If everything seems under control, you're not going fast enough." - Mario Andretti
Yesterday When I was Young.

jacortina

This block snippet shows the most recently STARTED topics (as opposed to the most recently posted to (which could be done calling ssi_recentTopics and having it return an array - search for it and you find example code using it):

http://www.tinyportal.net/index.php?topic=20698.msg170036#msg170036

heusdens

Hi there
Perfect, just what I was looking for!  thanks so much

heusdens

Hi

Just a quick one, how would I go about modifying this script to show the first 10 characters of the post title using the substr function?  Reason for this is because if a user makes a post with a long title (with no spaces) then it will mess up the look of the site.  Sorry for these requests but I'm very new to tinyportal/smf and I'm still learning.

jacortina

SMF has a subroutine for it which should be available to any block. Limits length and will append the '...' if trimmed.

Find:
$row['firstSubject']

Replace with:
shorten_subject($row['firstSubject'], 10)

You can tweak that '10' for the length to show once you see how it looks.

heusdens

Thank you

It works now.  For info here's the code:

global $scripturl, $settings, $db_prefix, $user_info, $modSettings;

$list_count = 20;
$request = db_query("
SELECT
ms.subject AS firstSubject, ms.posterTime AS firstPosterTime, ms.ID_TOPIC, t.ID_BOARD, b.name AS bname
FROM ({$db_prefix}messages AS ms, {$db_prefix}topics AS t, {$db_prefix}boards AS b)
WHERE   t.ID_TOPIC = ms.ID_TOPIC
AND b.ID_BOARD = t.ID_BOARD " . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? " AND b.ID_BOARD != $modSettings[recycle_board]" : '') . "
AND ms.ID_MSG = t.ID_FIRST_MSG
AND " . $user_info['query_see_board'] . "
ORDER BY t.ID_LAST_MSG DESC LIMIT " . $list_count, __FILE__, __LINE__);

echo '
<table border="0">';

while ($row = mysql_fetch_assoc($request))
echo ' <tr>
<td valign="middle"> <a href="',  $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;topicseen"><b>', shorten_subject($row['firstSubject'], 10) .'</b></a></td>
</tr>';

echo '
</table border>';

IchBin

For your future reference heusdens. please don't post for support in this board. Post in the request board. If your topic turns into a snippet we will move it. Thank you.

heusdens


This website is proudly hosted on Crocweb Cloud Website Hosting.