Started by TestMonkey, April 01, 2007, 09:59:05 PM

Previous topic - Next topic


Link to Mod

Thank you for you're interest in ssi_topicNews Mod by James L. Moss aka: TestMonkey.

This Mod is an updated and packaged version of the function originally posted and created by sting in this thread:

This Mod Adds a function that allows you to get and display a specific topic as an single story or article.

Example usage:
    ssi_topicNews($topic, $limit = null, $start = null, $length = null, $link = null, $output_method = 'array');


ssi_topicNews v0.8
- Changed the parse_bbc call to point to ID_TOPIC instead of ID_MSG this fixes a forum error log msg.

ssi_topicNews v0.7
- Cleaned up and changed the default output to a cleaner div style layout and removed the hard coded font coloring.

ssi_topicNews v0.6
- Cleaned up the cutoff/length code so it works more correctly helping to keep the output correct and more predictable.
- Shifted the parse_bbcode call up some to insure any and all output is sent thru it.

ssi_topicNews v0.5
- Cleaned up code a bit, updated the $length/$cutoff code to work correctly like how ssi_BoardNews() is done currently.
- Added new option $link, which allows you to pass a url into the function which generates a "Read More..." link.

ssi_topicNews v0.4
- Install Scripts now use install.mod and uninstall.mod so the package now cleanly uninstal's the modification.

ssi_topicNews v0.3
- Cleaned up the package install scripts

ssi_topicNews v0.2
- Added $board = null; to the function to eleminate errors in the forum logs.
- Added code to turn $topic into an integer
- Added code to default to $topic 2 which is the default first post if $topic 0 or 1 was defined

ssi_topicNews v0.1
- First release

TODO List:
- Keep Optimising the code in ssi_topicNews();
- Add upgrade ability to the package for version 1.0 and higher

1) $topic 0 or 1 can not be selected, It will default to 2 the default SMF first post..
2) If you get an parse error while trying to install the mod, go into:
    Packages -> Options, and Change all file permissions throughout the forum such that:: All files are writable.
    Manually chmod SSI.php to 666 or 777 through an ftp program.
    Now try to apply the modification again and it should work.
3) You need to play with the $length value some to get the desired short headline output.
4) If you use the $link variable it needs to point to the full story somewhere.

Contributors and other credits:
- Major credit to the SMF team for creating SMF & SSI.php especially for the functions we can use as a reference.
- Major credit to [Unknown] for all the hard work he's done and still does.
- Sting for the original code he posted here:
- Credit to winrules for noticing and suggesting the font color change in v0.7

Keep in mind this mod is still being developed.
Understand it works fine now but will keep being improved apon check for updates.
Knowledge is power

thank you... usefull mod.

i want to make a little modification.

i have day of history topics.

how can i change topic ID according to date (day+month)??

like this:
SIFIR proudly hosted by servega


Can you go into more detail what you are wanting to do, are you wanting to have the example script i provided generate topic IDs based off the current date?

Like say today is may 27th, are you wanting to find any/all topics created on "may 27th" and display them, basically putting together a daily listing of posts ?

I'm unclear on what you are wanting exactly, please take you're time and provide as much detail as possible in what you are requesting.
Knowledge is power


Does this mod also display attachments? I haven't figured out how to pull that of myself.


Not in the current release, that is a good catch but that raises some questions also..
Would we want guests/world to see attachments?
Or just allow logged in users, or just users of a specific group etc?

I'll work on adding the ability to see attachments tho in a new release within the next few weeks.
I may work on adding the ability to assign users/groups to a list that can see the attachments in a new seperate mod and add the functionality required into this mod so that they can work side by side.
I'll look thru the mods to see if a mod like the one im suggesting exists or not if one does i'll test it and add the functionality to my mod to work side by side with it.

Go ahead and post any idea's thoughts about this or anything else you can come up with.
Knowledge is power


Here's what I came up with for image attachments. It works, but it's very basic. May be a good starting point for you:

 // Return a single post //
function ssi_grabMessage($message_id null$output_method 'echo'

if (
$message_id !== null$message_id = (int) $message_id;
elseif (isset(
$_GET['ID_MSG'])) $message_id = (int) $_GET['ID_MSG'];
else die(
"Geen message id ingevoerd");

// This is needed for loadAttachmentContext()

// Fetch attachments.
if (!empty(
$modSettings['attachmentEnable']) && allowedTo('view_attachments'))
$request db_query("
a.ID_ATTACH, a.ID_MSG, a.filename, IFNULL(a.size, 0) AS filesize, a.downloads,
a.width, a.height" 
. (empty($modSettings['attachmentShowImages']) || empty($modSettings['attachmentThumbnails']) ? '' ",
IFNULL(thumb.ID_ATTACH, 0) AS ID_THUMB, thumb.width AS thumb_width, thumb.height AS thumb_height"
) . "
{$db_prefix}attachments AS a" . (empty($modSettings['attachmentShowImages']) || empty($modSettings['attachmentThumbnails']) ? '' "
{$db_prefix}attachments AS thumb ON (thumb.ID_ATTACH = a.ID_THUMB)") . "
AND a.attachmentType = 0"

$temp = array();
while (
$row mysql_fetch_assoc($request))
$temp[$row['ID_ATTACH']] = $row;

if (!isset(
$attachments[$row['ID_MSG']] = array();

// This is better than sorting it with the query...

foreach (
$temp as $row)
$attachments[$row['ID_MSG']][] = $row;

$request db_query("
m.icon, m.subject, m.body, IFNULL(mem.realName, m.posterName) AS posterName,
m.posterTime, m.ID_MSG, t.ID_TOPIC, m.ID_MEMBER, m.smileysEnabled,
{$db_prefix}topics AS t, {$db_prefix}messages AS m, {$db_prefix}boards as b)
{$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)
AND FIND_IN_SET(-1, b.memberGroups)
$return = array();

if (
mysql_num_rows($request) == 0) {
if (
$output_method == 'echo') die($txt['smf_news_error2']);
else return;

$row mysql_fetch_assoc($request);
$row['body'] = doUBBC($row['body'], $row['smileysEnabled']);


$return[] = array(
'icon' => '<img src="' $settings['images_url'] . '/post/' $row['icon'] . '.gif" align="middle" alt="' $row['icon'] . '" />',
'subject' => $row['subject'],
'time' => timeformat($row['posterTime']),
'body' => $row['body'],
'href' => $scripturl '?topic=' $row['ID_TOPIC'] . '.0',
'link' => '<a href="' $scripturl '?topic=' $row['ID_TOPIC'] . '.msg' $row['ID_MSG'] . '#msg' $row['ID_MSG'] . '">Read More...',
'new_comment' => '<a href="' $scripturl '?action=post;topic=' $row['ID_TOPIC'] . '.0">Reply</a>',
'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']) ? '<a href="' $scripturl '?action=profile;u=' $row['ID_MEMBER'] . '">' $row['posterName'] . '</a>' $row['posterName']
'attachment' => loadAttachmentContext($row['ID_MSG']),

if (
$output_method != 'echo') return $return;

foreach (
$return as $news) {
<table border="0" width="100%" align="center" class="smfNews">
$news['icon'], ' <b>'$news['subject'], '</b><span class="smaller"><br />'$news['time'], ' '$txt[525], ' '$news['poster']['link'], '<br /><br /></span></td></tr>
$news['body'], '<br /><br /></td></tr>
foreach (
$news['attachment'] as $attachedfile) {
<a href="'
$attachedfile['href'] , '";image" id="link_'$attachedfile['id'], '" onclick="'$attachedfile['thumbnail']['javascript'], '"><img src="'$attachedfile['thumbnail']['href'] .'" id="thumb_'$attachment['id'], '"></a>';
$news['link'], ' | '$news['new_comment'], '</td></tr>



Thx man ill look this over and work on adding the attachment functionality in new releases of my code =)
Knowledge is power


Due to several other projects coming up this has been put on the backburner to a degree but I do plan on releasing an update soon so stay tuned.
Knowledge is power


Will it contain a decent attachment integration?


Quote from: Vandaahl on June 04, 2007, 12:30:16 PM
Will it contain a decent attachment integration?
Read above.
Knowledge is power


How to extend visualization to all topic?


I'm no longer actively working on this mod, try:

it should have everything you

My mod should still work fine for 1.3, but i'm not going to be releasing any updates to it as Daniel's mod should do everything mine does more or less.
Knowledge is power