News:

Wondering if this will always be free?  See why free is better.

Main Menu

ssi.php

Started by johny000, August 24, 2008, 11:09:17 PM

Previous topic - Next topic

johny000

hello guys how are you
i'm useing  smf v 1.1.5

how can imake the  ssi_recentTopics

move like this
 
New Topics  will show like this  one after one  ( Topics # 2)   ( Topics # 3)   ( Topics # 4) ..... 
by adding <marquee></marquee> in the code
here is the code

// Recent topic list:   [board] Subject by Poster Date
function ssi_recentTopics($num_recent = 20, $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 />' => '&#10;')));
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 target="_blank" 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 target="_blank" 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 target="_blank" 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">

</td>
<td valign="top">
<a target="_blank" href="', $post['href'], '">', $post['subject'], '</a>
', $txt[525], ' ', $post['poster']['link'], '
', $post['new'] ? '' : '<a target="_blank" href="' . $scripturl . '?topic=' . $post['topic'] . '.msg' . $post['new_from'] . ';topicseen#new">', '
</td>
<td align="right" nowrap="nowrap">

</td>
</tr>';
echo '
</table>';
}


any idea?

spearfish

Seems simple enough :-)

Don't go editing your SSI file, that makes upgrading a hassle... and besides, you might want to use the native functionality of ssi_recentTopics someday ;-)

Try this change.  Before, you would just have this:

<?php
ssi_recentTopics
()
?>



Change that to this (make sure you include SSI.php at the start of this page):

<?php
// Change the 20 to however many recent posts you want included
$posts ssi_recentTopics(20null'array');
echo 
"<marquee>- ";
foreach (
$posts as $post)
echo 
"<a href='{$post['href']}'>{$post['subject']}</a> ({$post['poster']['link']}) - ";
echo 
"</marquee";
?>



I'm not 100% sure how to get it to work with the "new!" blue buttons, maybe somebody else can shine some light on that... but otherwise, that *should* work :-)

Nice idea by the way.

johny000

i fix it just like the way i want it
<?php
// Change the 20 to however many recent posts you want included
$posts ssi_recentTopics(20null'array');
echo 
"<marquee onMouseOver='this.stop()' onMouseOut='this.start()'>";
foreach (
$posts as $post)
echo 
"<FONT COLOR='YELLOW' >{$post['poster']['link']}</FONT>:&nbsp;&nbsp;<a target='_blank' href='{$post['href']}'>{$post['subject']}</a><img src='logo.gif' width='22' height='22' border='0'>";
echo 
"</marquee>";
?>

& is work 100%  woow thank you soooooooo muchhhh you just made my day

johny000

is there is anyway ican add also

last post by:   ({$post['poster']['link']})  subject <a href='{$post['href']}'>{$post['subject']}</a>


some thing like this the one with green


spearfish

I'm not sure what you mean by this.

Are you after the last post by each of the members?  That would require you to code the actual function as there is no SSI.php shortcut for that.  There'd also have to be some database changes to keep this from being totally inefficient.

* spearfish stores this mod idea in the back of his head.

Here's all that's possible with SSI.php  Changing the way a function spits out the data is very easy, while making a totally new function will may be very difficult.

johny000

will what i'm trying to do is  put the  user name some thing will say lost post By & the  the user name  &  by the  subject code subject & then is will show subject

i'm not sure if i'm saying it as right waay but i want it will look like this


Posted by : johny000  subject : hello guys how are you all - Posted by :  spearfish  subject :  i thing i can make it - Posted by :  johny000  subject : plez try


i hope  you get me now

thank you for your try

spearfish

Oh!  That's a lot easier :-)

We have two options for what function to use.  If we use ssi_recentTopics(), then it returns the most recently updated topics.  If we use ssi_recentPosts(), then it will give us the most recent posts... the difference?  If you use recentTopics, then you'll only get one post maximum from each topic - whereas with recentPosts all of them could be from the same topic.

Because I like recentPosts better, I'll show you the code with that.  But feel free to change it.  This will also link to user profiles and the topic.


$posts = ssi_recentPosts(20, null, 'vivo');
echo "<marquee onMouseOver='this.stop()' onMouseOut='this.start()'>";

foreach ($posts as $post) {
echo "<span style='color:green;'>Posted by: </span>";
echo "<span style='color:black;'>{$post['poster']['link']} </span>";
echo "<span style='color;gray;'>Subject: </span>";
echo "<span style='color:black;'>{$post['link']} - </span>";
}

echo "</marquee>";


Let me know how that works.

katib

#7
Quote from: spearfish on August 29, 2008, 01:23:33 AM

Let me know how that works.
many thanks
althought I am not the topic starter, I can say: it worked great for me !!
so please, how can add the number of replies ?
I tried:
$topic['replies']
with no success
منتدى الحجاج ... منتدى للقراءة والكتاب
http://www.hijaj.net

spearfish

Try using $topic['num_replies'].

[SiNaN]

You should add it to the query and the $posts array first.
Former SMF Core Developer | My Mods | SimplePortal

spearfish

Yes... it would take a bit of playing with the SSI.php file to get that to work with ssi_recentPosts.  But because he talked about using $topic it made me think he modified my code to use ssi_recentTopics and then changed some variables so that it would make more sense.

katib

#11
Thank you very much spearfish
Quote from: spearfish on October 08, 2008, 06:47:17 PM
Try using $topic['num_replies'].
I add it with no succes  :-[

@ SiNaN
thank you very much
Quote from: [SiNaN] on October 08, 2008, 07:35:27 PMYou should add it to the query and the $posts array first.
but can you elaborate more? I am a newbie

Anyway this is the code I am  using
It does exactly what I want, I wish you could help me  to add the total number of replies and possibly, the date



// ٌRecents topics Change the 20 to however many recent posts you want included
echo '
<div class="tborder" ', $context['browser']['needs_size_fix'] && !$context['browser']['is_ie6'] ? ' style="width: 100%;"' : '', '>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="catbg" height="32"><span style="font-family: Verdana, sans-serif; font-size: 140%; ">آخر المشاركات</span></td></tr></table>';


include('SSI.php');
$posts = ssi_recentTopics(10, null, 'vivo');
echo '
<table width="100%" class="bordercolor" cellpadding="8" cellspacing="0" border="0" style="margin-top: 1px;">
<tr class="windowbg2"><td class="windowbg" valign="middle">';
echo "<marquee direction='right' onMouseOver='this.stop()' onMouseOut='this.start()'>";

foreach ($posts as $post) {
echo "<span style='color:black;'>{$post['link']} - </span>";
echo "<span style='color:green;'>{$txt['last_post']}: </span>";
echo "<span style='color:black;'>{$post['poster']['link']} </span>&nbsp;&nbsp;.::.&nbsp;&nbsp;";
}

echo "</marquee></td></tr></table>";
منتدى الحجاج ... منتدى للقراءة والكتاب
http://www.hijaj.net

spearfish

Oh hey... you're using different variable names than I'd thought you were x.x

What should work here is $post['num_replies'].

And since you're using ssi_recentTopics you shouldn't need to modify the code for SSI.php.

katib

thank you so much
once again, it didnot work for me  :-[
maybe I am oing something wrong, or I should add some code elswhere

here is the new modified code:


<?php
// ٌRecents topics Change the 20 to however many recent posts you want included
echo '
<div class="tborder" '
$context['browser']['needs_size_fix'] && !$context['browser']['is_ie6'] ? ' style="width: 100%;"' '''>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="catbg" height="32"><span style="font-family: Verdana, sans-serif; font-size: 140%; ">آخر المشاركات</span></td></tr></table>'
;


include('SSI.php');
$posts ssi_recentTopics(10null'vivo');
echo '
<table width="100%" class="bordercolor" cellpadding="8" cellspacing="0" border="0" style="margin-top: 1px;">
<tr class="windowbg2"><td class="windowbg" valign="middle">'
;
echo 
"<marquee direction='right' onMouseOver='this.stop()' onMouseOut='this.start()'>";

foreach (
$posts as $post) {
echo 
"<span style='color:black;'>{$post['link']} - </span>";
echo 
"<span style='color:green;'>{$txt['last_post']}: </span>";
echo 
"<span style='color:black;'>{$post['poster']['link']} </span>";
echo 
"<span style='color:black;'>{$txt['replies']}</span>";
echo 
"<span style='color:black;'>{$post['num_replies']} </span>&nbsp;&nbsp;.::.&nbsp;&nbsp;";
}

echo 
"</marquee></td></tr></table>";
?>
منتدى الحجاج ... منتدى للقراءة والكتاب
http://www.hijaj.net

spearfish

OK I feel really dumb.  The code I was referencing was from a completely different function within SSI.php.

x.x

So what you're going to want to do is modify the database query to pull the number of replies a topic has too.  Change lines 353-357 to this: (should look pretty much the same)


SELECT
t.num_replies, 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


then between lines 408 and 409 add this line:


$num_replies = $row['numReplies']


And then it should work.

katib

#15
hope this will work
But I am not sure about the exact location of the code to change
For the first change: since, I didnot fint the mentined code at lines  353-357 , I think you are refering to 4 lines located after this sentence:
// Find all the posts. Newer ones will have higher IDs.
( in my ssi.php file, those lins are located between lines 324 and 327 !!!)
so are you refering to those line:
// Find all the posts. Newer ones will have higher IDs.
$request = $smcFunc['db_query']('substring', '
SELECT
m.poster_time, m.subject, m.id_topic, m.id_member, m.id_msg, m.id_board, b.name AS board_name,
IFNULL(mem.real_name, m.poster_name) AS poster_name, ' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . ', ' . ($limit_body ? 'SUBSTRING(m.body, 1, 384) AS body' : 'm.body') . ', m.smileys_enabled



- For the second change, I dont know where to insert this line:
$num_replies = $row['numReplies']
in my ssi.php file, between  lines 408 and 409, we are in the middle of a fontion !!!!....
منتدى الحجاج ... منتدى للقراءة والكتاب
http://www.hijaj.net

spearfish

You're using 2.0 aren't you :P

Have any of your mods editing SSI.php?  If not I can just make the changes myself and give you a clean-ish copy with the function updated.

katib

Quote from: spearfish on October 09, 2008, 09:49:52 PM
You're using 2.0 aren't you :P
I dont know, I know only using SMF 2 beta 4 ( an upgrade from smf1.1.6 )

Quote from: spearfish on October 09, 2008, 09:49:52 PM

Have any of your mods editing SSI.php?  If not I can just make the changes myself and give you a clean-ish copy with the function updated.
No, I  dont have any mod anstalled yet
so a "clean-ish copy with the function updated" will be more helpfull and more appreciated by a newbie like me

منتدى الحجاج ... منتدى للقراءة والكتاب
http://www.hijaj.net

[SiNaN]

Well, it would have been better if you had mentioned the version you are using. You should use 'replies' index. In your case $post['replies'].
Former SMF Core Developer | My Mods | SimplePortal

spearfish

wait... so that's included by default in 2.0?  neat!

i haven't played around much with 2.0, maybe i should :P

Advertisement: