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

Recent

Welcome to TinyPortal. Please login or sign up.

April 30, 2024, 03:38:04 PM

Login with username, password and session length
Members
  • Total Members: 3,885
  • Latest: Growner
Stats
  • Total Posts: 195,174
  • Total Topics: 21,220
  • Online today: 147
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 121
  • Total: 121

Currently Active Topics

Started by Sarke, May 14, 2007, 12:10:39 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

tick

I am sorry bro.  I am not thinking straight today.  I did not add the link.   :2funny:    Here see if this works better.  lol   http://www.tinyportal.net/index.php?topic=1234.0

kopijun


kopijun

Well I've tried those links view days ago, but in fact I like the style of Sarke's code more better...Is there a way to select topics from certain board but with this Sarke's style ?

I mean with this style :

Quote from: Sarke on May 14, 2007, 12:10:39 AM

<?php

if (!defined('SMF'))
die('Hacking attempt...');

global $context$user_info$db_prefix$scripturl;

$days 7;
$limit 5;

$time time() - 60*60*24*$days;

$result db_query("
SELECT b.ID_BOARD as board
FROM 
{$db_prefix}boards AS b
WHERE 
{$user_info['query_see_board']}
"
__FILE____LINE__);

$boards = array();
while ($row mysql_fetch_array($result))
{
$boards[] = $row['board'];
}
mysql_free_result($result);

$result db_query("
SELECT ID_TOPIC as id, COUNT(*) as posts
FROM 
{$db_prefix}messages
WHERE posterTime > 
$time
AND ID_BOARD IN (" 
implode(','$boards) . ")
GROUP BY ID_TOPIC
ORDER BY posts DESC
LIMIT 
$limit
"
__FILE____LINE__);

$topics = array();
while ($row mysql_fetch_array($result))
{
$topics[$row['id']]['posts'] = $row['posts'];
}
mysql_free_result($result);

if (empty($topics))
{
echo '<div class="smalltext">No topics to display.</div>';
}
else
{
echo '
<table cellspacing="0" cellpadding="0" style="width: 100%; margin: 0px; padding: 0px;">'
;

$result db_query("
SELECT ID_TOPIC as id, subject, MAX(ID_MSG) as msg, MAX(posterTime) as time
FROM 
{$db_prefix}messages
WHERE ID_TOPIC IN (" 
implode(','array_keys($topics)) . ")
GROUP BY ID_TOPIC
"
__FILE____LINE__);

while ($row mysql_fetch_array($result))
{
$topics[$row['id']]['subject'] = $row['subject'];
$topics[$row['id']]['msg'] = $row['msg'];
$topics[$row['id']]['time'] = $row['time'];
}
mysql_free_result($result);

foreach ($topics as $id => $topic)
{
if (empty($first))
{
$first true;
}
else
{
echo '
<tr><td colspan="2"><hr size="1" width="100%" class="hrcolor" /></td></tr>'
;
}

echo '
<tr>
<td align="left">
<div class="smalltext"><a href="'
$scripturl'?topic='$id'.msg'$topic['msg'], '#new">'$topic['subject'], '</a></div>
<div class="smalltext">['
timeformat($topic['time']), ']</div>
</td>
<td align="right"><div class="smalltext">'
$topic['posts'], '</div></td>
</tr>'
;
}

echo '
</table>'
;
}

?>




tick

I wish I could help  you there but I am not much of a coder.   :(  give it a little time and maybe one of the coders can help.

kopijun

nevermind  :)
Thanks anyway...

Sarke

kopijun, just replace


WHERE {$user_info['query_see_board']}


with


WHERE {$user_info['query_see_board']}
AND b.ID_BOARD IN (1, 2, 3)


Where the "1, 2, 3" part is the IDs of the boards you want.

RoarinRow

Thanks for this code.  It's solved my problem with my Recent Topics block not showing the correct number of topics to guests and other grouped members.

SMF 2.0 RC3
TP 1.0 beta 5-1
Wordpress 3.0