News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Number of recent topics displayed in SSI

Started by spiros, March 02, 2008, 07:46:38 PM

Previous topic - Next topic

spiros

I use this SSI to display the 10 most recent topics from given boards.
However, when there were no recent posts (last few days) in these boards, it only displays a limited amount of entries. Is it possible to make it display the 10 most recent topics, no matter how old they are?

You can see it at work here Translatum Greek translation portal

You see 3 different categories

Latest Translation Topics  [displays 10]
Latest Computer and CAT tools tips [displays 3]
Latest General Topics [displays 10]


<?php

$array 
ssi_recentTopics(10, array(1,2,3,4,5,6,7,8,9,10,14,15,18,19,20,21,22,23,24,26,27,33,34,36,37,38,39,41,42,45,46,49,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,84,85,86,87,88,89,91), 'array');
foreach (
$array as $recent)
{
        
$subject html_entity_decode($recent['subject']);
        if (
strlen($subject) > 250)
                
$subject htmlentities(substr($subject0250)) . '...';
        else
                
$subject $recent['subject'];
        echo 
' <tr bgcolor="#999999"><td><span class="textb"> <img src="images/dot.gif" alt="" width="11" height="11" /> <a href="'$recent['href'], ' - Poster: '$recent['poster']['name'], '">'$subject'</a>  '$recent '<a href="' $scripturl '?topic=' $recent['topic'] . '.from' $recent['newtime'] . $settings['images_url'] . '/' $context['user']['language'] . $txt[302] . '" border="0" /></a> ''''<br/> </span> </td> </tr>';
}
?>


TechniShawn

I have the same issue. I want to display the last 20 topics in an array of forums...

I use:


ssi_recentTopics(20, array(), 'echo', array(54,38,37,57), null);


But I am only getting 6 topics.... Not 20.

spiros

Well, I think an SSI function needs to be changed... but we need some code wizard to help us  ;)

Kindred

unless I am greatly mistaked:

ssi_recentTopics only has  3 passed variables:

number of topics, excluded board(s), format (array or echo)

so
ssi_recentTopics(20, array(1,2,5), 'array');

would pull the 20 most recent topics from all boards EXCEPT board 1, board 2 and board 5.

there is nothing inherant in the code to not display based on date...  unless you have modified the code.

tehcniShawn,   your function call is WAY messed up (see above)
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

spiros

Quote from: Kindred on April 09, 2008, 02:47:24 PM
there is nothing inherant in the code to not display based on date...  unless you have modified the code.

I think there is, I think Unknown once told me that I need to create my own function in order to for all recent posts to be displayed as defined in the array.

Another proof for that, check my site (below).

TechniShawn

Quote from: Kindred on April 09, 2008, 02:47:24 PM
unless I am greatly mistaked:

ssi_recentTopics only has  3 passed variables:

number of topics, excluded board(s), format (array or echo)

so
ssi_recentTopics(20, array(1,2,5), 'array');

would pull the 20 most recent topics from all boards EXCEPT board 1, board 2 and board 5.

there is nothing inherant in the code to not display based on date...  unless you have modified the code.

tehcniShawn,   your function call is WAY messed up (see above)


from ssi.php


function ssi_recentTopics($num_recent = 8, $exclude_boards = null, $output_method = 'echo', $include_boards = null, $member_id = null)


My function code is indeed correct.

TechniShawn

What does this statement do?


AND m.posterTime > " . (time() - ($_REQUEST['limit']*24*60*60)) : '') . (!empty($member_id) ? "

metallica48423

#7
1.1.4:
function ssi_recentTopics($num_recent = 8, $exclude_boards = null, $output_method = 'echo')

2.0:
function ssi_recentTopics($num_recent = 8, $exclude_boards = null, $include_boards = null, $output_method = 'echo')

Techishawn, try this:

ssi_recentTopics(20, '', array(54,38,37,57), 'echo');

spiros:  are you really meaning to EXCLUDE all those boards?

Quote from: TechniShawn on April 09, 2008, 03:13:23 PM
What does this statement do?


AND m.posterTime > " . (time() - ($_REQUEST['limit']*24*60*60)) : '') . (!empty($member_id) ? "


Where did you find that?  This is the recentTopics query for 2.0 beta 3 public:


// Find all the posts in distinct topics.  Newer ones will have higher IDs.
$request = $smcFunc['db_query']('', '
SELECT
m.poster_time, ms.subject, m.id_topic, m.id_member, m.id_msg, b.id_board, b.name AS board_name, t.num_replies, t.num_views,
IFNULL(mem.real_name, m.poster_name) AS poster_name, ' . ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS isRead,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . ', SUBSTRING(m.body, 1, 384) AS body, m.smileys_enabled, m.icon
FROM {db_prefix}topics AS t
INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_last_msg)
INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
INNER JOIN {db_prefix}messages AS ms ON (ms.id_msg = t.id_first_msg)
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = t.id_topic AND lt.id_member = {int:current_member})
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = {int:current_member})' : '') . '
WHERE t.id_last_msg >= {int:min_message_id}
' . (empty($exclude_boards) ? '' : '
AND b.id_board NOT IN ({array_int:exclude_boards})') . '
' . (empty($include_boards) ? '' : '
AND b.id_board IN ({array_int:include_boards})') . '
AND ' . $user_info['query_wanna_see_board'] . ($modSettings['postmod_active'] ? '
AND t.approved = {int:is_approved}
AND m.approved = {int:is_approved}' : '') . '
ORDER BY t.id_last_msg DESC
LIMIT ' . $num_recent,
array(
'current_member' => $user_info['id'],
'include_boards' => empty($include_boards) ? '' : $include_boards,
'exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards,
'min_message_id' => $modSettings['maxMsgID'] - 35 * min($num_recent, 5),
'is_approved' => 1,
)
);
Justin O'Leary
Ex-Project Manager
Ex-Lead Support Specialist

QuoteMicrosoft wants us to "Imagine life without walls"...
I say, "If there are no walls, who needs Windows?"


Useful Links:
Online Manual!
How to Help us Help you
Search
Settings Repair Tool

Kindred

technishawn,

That function that you list is NOT the standard SSI function.
http://support.simplemachines.org/function_db/index.php?action=view_function;function=590

1.1.4
function ssi_recentTopics($num_recent = 8, $exclude_boards = null, $output_method = 'echo')

2.0b3
function ssi_recentTopics($num_recent = 8, $exclude_boards = null, $include_boards = null, $output_method = 'echo')

neither of them match your code.

and again...   the line about m.posterTime is not part of the standard SSI.php ssi_recentTopics function.


(Metallica beat me to it, but I am going to post anyway)

Actually, Metallica... my 2.0 SSI.php doies not have that code...
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

metallica48423

#9
Kindred is correct, i however was wrong.

i pulled the SSI from 2.0 beta 2.1 by mistake.  I will replace the information in my post with the proper syntax.  I apoligize

Techishawn, try this:

[code]ssi_recentTopics(20, '', array(54,38,37,57), 'echo');

edit: fixed above post
Justin O'Leary
Ex-Project Manager
Ex-Lead Support Specialist

QuoteMicrosoft wants us to "Imagine life without walls"...
I say, "If there are no walls, who needs Windows?"


Useful Links:
Online Manual!
How to Help us Help you
Search
Settings Repair Tool

TechniShawn

I have a standard install of smf 1.1.4

I pulled the info directly from my UNMODIFIED ssi.php file

You tell me where it came from.....


**********************************************************************************
* SSI.php                                                                         *
***********************************************************************************
* SMF: Simple Machines Forum                                                      *
* Open-Source Project Inspired by Zef Hemel ([email protected])                    *
* =============================================================================== *
* Software Version:           SMF 1.1                                             *
* Software by:                Simple Machines (http://www.simplemachines.org)     *
* Copyright 2006 by:          Simple Machines LLC (http://www.simplemachines.org) *
*           2001-2006 by:     Lewis Media (http://www.lewismedia.com)             *
* Support, News, Updates at:  http://www.simplemachines.org                       *
***********************************************************************************
* This program is free software; you may redistribute it and/or modify it under   *
* the terms of the provided license as published by Simple Machines LLC.          *
*                                                                                 *
* This program is distributed in the hope that it is and will be useful, but      *
* WITHOUT ANY WARRANTIES; without even any implied warranty of MERCHANTABILITY    *
* or FITNESS FOR A PARTICULAR PURPOSE.                                            *
*                                                                                 *
* See the "license.txt" file for details of the Simple Machines license.          *
* The latest version can always be found at http://www.simplemachines.org.        *
**********************************************************************************/

Kindred

I don't know where it came from...   but the SSI that is available for download with the SMF packages here on simplemachines.org does not have that line.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

TechniShawn

that's wierd. I wonder if a mod I installed replaced the ssi.php  file?

metallica48423

the entire function from 1.1.4, unmodded :):


// Recent topic list:   [board] Subject by Poster Date
function ssi_recentTopics($num_recent = 8, $exclude_boards = null, $output_method = 'echo')
{
global $context, $settings, $scripturl, $txt, $db_prefix, $ID_MEMBER;
global $user_info, $modSettings, $func;

if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0)
$exclude_boards = array($modSettings['recycle_board']);
else
$exclude_boards = empty($exclude_boards) ? array() : $exclude_boards;

$stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
$icon_sources = array();
foreach ($stable_icons as $icon)
$icon_sources[$icon] = 'images_url';

// Find all the posts in distinct topics.  Newer ones will have higher IDs.
$request = db_query("
SELECT
m.posterTime, ms.subject, m.ID_TOPIC, m.ID_MEMBER, m.ID_MSG, b.ID_BOARD, b.name AS bName,
IFNULL(mem.realName, m.posterName) AS posterName, " . ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) >= m.ID_MSG_MODIFIED AS isRead,
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . ", LEFT(m.body, 384) AS body, m.smileysEnabled, m.icon
FROM ({$db_prefix}messages AS m, {$db_prefix}topics AS t, {$db_prefix}boards AS b, {$db_prefix}messages AS ms)
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)" . (!$user_info['is_guest'] ? "
LEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
LEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = b.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)" : '') . "
WHERE t.ID_LAST_MSG >= " . ($modSettings['maxMsgID'] - 35 * min($num_recent, 5)) . "
AND t.ID_LAST_MSG = m.ID_MSG
AND b.ID_BOARD = t.ID_BOARD" . (empty($exclude_boards) ? '' : "
AND b.ID_BOARD NOT IN (" . implode(', ', $exclude_boards) . ")") . "
AND $user_info[query_see_board]
AND ms.ID_MSG = t.ID_FIRST_MSG
ORDER BY t.ID_LAST_MSG DESC
LIMIT $num_recent", __FILE__, __LINE__);
$posts = array();
while ($row = mysql_fetch_assoc($request))
{
$row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileysEnabled'], $row['ID_MSG']), array('<br />' => '')));
if ($func['strlen']($row['body']) > 128)
$row['body'] = $func['substr']($row['body'], 0, 128) . '...';

// Censor the subject.
censorText($row['subject']);
censorText($row['body']);

if (empty($modSettings['messageIconChecks_disable']) && !isset($icon_sources[$row['icon']]))
$icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.gif') ? 'images_url' : 'default_images_url';

// Build the array.
$posts[] = array(
'board' => array(
'id' => $row['ID_BOARD'],
'name' => $row['bName'],
'href' => $scripturl . '?board=' . $row['ID_BOARD'] . '.0',
'link' => '<a href="' . $scripturl . '?board=' . $row['ID_BOARD'] . '.0">' . $row['bName'] . '</a>'
),
'topic' => $row['ID_TOPIC'],
'poster' => array(
'id' => $row['ID_MEMBER'],
'name' => $row['posterName'],
'href' => empty($row['ID_MEMBER']) ? '' : $scripturl . '?action=profile;u=' . $row['ID_MEMBER'],
'link' => empty($row['ID_MEMBER']) ? $row['posterName'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['posterName'] . '</a>'
),
'subject' => $row['subject'],
'short_subject' => shorten_subject($row['subject'], 25),
'preview' => $row['body'],
'time' => timeformat($row['posterTime']),
'timestamp' => forum_time(true, $row['posterTime']),
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . ';topicseen#new',
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . '#new">' . $row['subject'] . '</a>',
'new' => !empty($row['isRead']),
'new_from' => $row['new_from'],
'icon' => '<img src="' . $settings[$icon_sources[$row['icon']]] . '/post/' . $row['icon'] . '.gif" align="middle" alt="' . $row['icon'] . '" border="0" />',
);
}
mysql_free_result($request);

// Just return it.
if ($output_method != 'echo' || empty($posts))
return $posts;

echo '
<table border="0" class="ssi_table">';
foreach ($posts as $post)
echo '
<tr>
<td align="right" valign="top" nowrap="nowrap">
[', $post['board']['link'], ']
</td>
<td valign="top">
<a href="', $post['href'], '">', $post['subject'], '</a>
', $txt[525], ' ', $post['poster']['link'], '
', $post['new'] ? '' : '<a href="' . $scripturl . '?topic=' . $post['topic'] . '.msg' . $post['new_from'] . ';topicseen#new"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $txt[302] . '" border="0" /></a>', '
</td>
<td align="right" nowrap="nowrap">
', $post['time'], '
</td>
</tr>';
echo '
</table>';
}


So you should have this: function ssi_recentTopics($num_recent = 8, $exclude_boards = null, $output_method = 'echo')

So you'd use
ssi_recentTopics(20, array(54,38,37,57), 'echo');

I also don't see that part of the query which you posted :(
Justin O'Leary
Ex-Project Manager
Ex-Lead Support Specialist

QuoteMicrosoft wants us to "Imagine life without walls"...
I say, "If there are no walls, who needs Windows?"


Useful Links:
Online Manual!
How to Help us Help you
Search
Settings Repair Tool

TechniShawn

craziness....


here is the query I have:


$request = db_query("
SELECT
{$extravalues}
m.posterTime, ms.subject, m.ID_TOPIC, m.ID_MEMBER, m.ID_MSG, b.ID_BOARD, b.name AS bName,
IFNULL(mem.realName, m.posterName) AS posterName, " . ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) >= m.ID_MSG_MODIFIED AS isRead,
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . ", LEFT(m.body, 384) AS body, m.smileysEnabled, m.icon
FROM ({$db_prefix}messages AS m, {$db_prefix}topics AS t, {$db_prefix}boards AS b, {$db_prefix}messages AS ms)
LEFT JOIN {$db_prefix}members AS memfp ON (memfp.ID_MEMBER = ms.ID_MEMBER)
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)" . (!$user_info['is_guest'] ? "
LEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
LEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = b.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)" : '') . "
WHERE t.ID_LAST_MSG >= " . ($modSettings['maxMsgID'] - 35 * min($num_recent, 5)) . "
AND t.ID_LAST_MSG = m.ID_MSG
AND b.ID_BOARD = t.ID_BOARD" . (empty($exclude_boards) ? '' : "
AND b.ID_BOARD NOT IN (" . implode(', ', $exclude_boards) . ")") . (!empty($include_boards) ? "
AND b.ID_BOARD IN (" . implode(', ', $include_boards) . ")"  : '') . ($output_method == 'extended' && isset($_REQUEST['limit']) && is_numeric($_REQUEST['limit']) ? "
AND m.posterTime > " . (time() - ($_REQUEST['limit']*24*60*60)) : '') . (!empty($member_id) ? "
AND m.ID_MEMBER = {$member_id}" : '') . "
AND $user_info[query_see_board]
AND ms.ID_MSG = t.ID_FIRST_MSG
ORDER BY " . ($output_method == 'extended' && isset($_REQUEST['sort']) ? (
$_REQUEST['sort'] . ($context['ascending'] ? '' : ' DESC')) : ("t.ID_LAST_MSG DESC")) . "
LIMIT " . (($output_method == 'extended' && isset($_REQUEST['start']) && isset($_REQUEST['action']) && $_REQUEST['action'] == 'recenttopics' && is_numeric($_REQUEST['start'])) ? ($_REQUEST['start'].', ') : ('')) . $num_recent, __FILE__, __LINE__);

metallica48423

where did you originally download or install SMF from?

What mods do you have installed.?

you probably could just completely remove this line

AND m.posterTime > " . (time() - ($_REQUEST['limit']*24*60*60)) : '') . (!empty($member_id) ? "
Justin O'Leary
Ex-Project Manager
Ex-Lead Support Specialist

QuoteMicrosoft wants us to "Imagine life without walls"...
I say, "If there are no walls, who needs Windows?"


Useful Links:
Online Manual!
How to Help us Help you
Search
Settings Repair Tool

TechniShawn

I found the mod that did it.

http://custom.simplemachines.org/mods/index.php?mod=654

"Recent posts user preference"

I will try uninstalling the mod and see what happens....

Kindred

he should probably remove this line as well...

code]
AND m.ID_MEMBER = {$member_id}" : '') . "


actually...    he should probably replace his SSI with a clean version.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

TechniShawn

ok. I uninstalled the mod and copied in a clean ssi.php from my 1.1.4 download package.

I am using the function call

ssi_recentTopics(20, array(1,2,3,8,9,10,11,12,14,15,16,17,23,35,36,41,46,47,48,49,50,51,52,55,56), 'echo');


but I am still only getting 6 topics .......


This one does the the rest of the forum and works just like it should:

ssi_recentTopics(20, array(54,38,37,57), 'echo');


metallica48423

keep in mind that the array in 1.1.4 is *exclude boards*, not the include boards.

Justin O'Leary
Ex-Project Manager
Ex-Lead Support Specialist

QuoteMicrosoft wants us to "Imagine life without walls"...
I say, "If there are no walls, who needs Windows?"


Useful Links:
Online Manual!
How to Help us Help you
Search
Settings Repair Tool

Advertisement: