collapse

* Simple Portal Archived Forum

This is an Archive Forum.

The content in this forum may be out-of-date or have been superseded by newer information, and links in forum pages to other sites may not work.
This forum contains archives for future reference.

Visit our thread at Simple Machines Forum for current support.

SMF 2.1 users: EhPortal is a ported version of Simple Portal specifically designed for the SMF 2.1 branch.
Please visit web-develop.ca to download EhPortal and for its support.

* User Info

 
 
Welcome, Guest. Please login or register.

* Who's Online

  • Dot Guests: 516
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

* Shoutbox

Refresh History
  • Shoutbox is not for support!
  • {OCS}MasterSeal: Yup, Still adore SP
    April 21, 2019, 07:08:06 PM
  • {OCS}MasterSeal: STILL love SP :)
    November 24, 2018, 05:05:50 AM
  • ♦ Ninja ZX-10RR ♦: <3 aegersz
    September 13, 2018, 03:36:09 PM
  • aegersz: I STILL <3 LOVE SimplePortal
    September 13, 2018, 07:11:39 AM
  • aegersz: o LOVE you guys - Simple Portal rocks !
    May 09, 2018, 05:18:59 AM
  • Chen Zhen: our apologies for the site being down.. please read server issues topic
    March 22, 2018, 05:32:38 AM
  • {OCS}MasterSeal: LOL PLEASE forget I just posted that. I found the answer in my own dang post back in 2015. lol sorry!
    July 04, 2017, 10:47:55 PM
  • {OCS}MasterSeal: I know this SB isnt' for support, but I just have a general question. Who would I contact to find out where SP stores its block info? Is it DB driven or files? I searched the site but came up with nothing. probably my fault any insight is appreciated.
    July 04, 2017, 10:43:36 PM
  • ♦ Ninja ZX-10RR ♦: Excuse me but what does Simpleportal have to deal with that?
    February 05, 2017, 08:21:14 PM
  • WhiteEagle: of course IMHO that site appears to be dead :(
    February 04, 2017, 01:08:05 PM
  • WhiteEagle: If I can get that, then I'll use it for that site...
    February 04, 2017, 01:07:35 PM
  • WhiteEagle: decided to not use SMF for any projects, unless I can get a copy of the premium version of the fanfiction archive plugin
    February 04, 2017, 01:06:54 PM
  • expertdecisions: cloudflare
    January 28, 2017, 08:01:47 AM
  • aegersz: SM release 2.0.13 !
    January 12, 2017, 06:00:13 AM
  • raffo: Tks Emanuele, even if I didn't understand the fix :D
    November 07, 2016, 02:01:20 AM
  • emanuele: [link]
    November 01, 2016, 12:43:50 PM
  • emanuele: raffo: the English support board is a good place. ;)
    November 01, 2016, 12:43:38 PM
  • raffo: Where can I find the fix for the shoutbox?
    November 01, 2016, 05:06:09 AM
  • {OCS}MasterSeal: To the SP team, I make a point to come here and thank you as much as possible for your work.  so again, THANK YOU!
    October 28, 2016, 10:38:05 AM
  • emanuele: That's indeed funny, the limit is present only in the patch and not the full install.
    October 22, 2016, 06:14:58 PM

* Recent Posts

Adding Forums Button to Nav bar by jirapon
[August 01, 2019, 09:07:12 AM]


Re: Board Icons by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 04:03:41 PM]


MOVED: Czech translation???? by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 03:04:51 PM]


Board Icons by jirapon
[July 30, 2019, 07:28:44 AM]


Re: Thankyou Simpleportal, by ♦ Ninja ZX-10RR ♦
[July 29, 2019, 09:41:29 AM]

Installation errors? Mod incompatibilities? Upgrade problems? Make your way over to the Install and Upgrade Support board for all your solutions!

Author Topic: sp_recent modification to show the post owner  (Read 5524 times)

0 Members and 1 Guest are viewing this topic.

Offline cedrict

  • Semi Newbie
  • *
  • Posts: 5
  • SMF Version: 1.1.12
  • SP Version: 2.3.3
sp_recent modification to show the post owner
« on: February 15, 2011, 10:15:01 AM »
Hello,

It's my firt post, so I try the search fonction before ask your help. Sorry for my english.

I use your simple portal 2.3.3 on my smf 1.1.12 and it's so wonderfull but i'd like to add one modification to sp_recent in PortalBlocks.php to show the post owner. I'm neewbie in php and I don't find hox to to that. Can you help me ?

So the code is :

Code: [Select]
if ($display == 'compact')

{

foreach ($items as $key => $item)

echo '

<a href="', $item['href'], '">', $item['subject'], '</a> <span class="smalltext">', $txt[525], ' ', $item['poster']['link'], $item['new'] ? '' : ' <a href="' . $scripturl . '?topic=' . $item['topic'] . '.msg' . $item['new_from'] . ';topicseen#new" rel="nofollow"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $txt[302] . '" border="0" /></a>', '<br />[', $item['time'], ']</span><br />', empty($item['is_last']) ? '<hr />' : '';

}

i try to do this :

Code: [Select]
if ($display == 'compact')

{

foreach ($items as $key => $item)

echo '

<a href="', $item['href'], '">', $item['subject'], '</a> <span class="smalltext">, $txt[525],',item['owner']['link']'', $txt[525a], ' ', $item['poster']['link'], $item['new'] ? '' : ' <a href="' . $scripturl . '?topic=' . $item['topic'] . '.msg' . $item['new_from'] . ';topicseen#new" rel="nofollow"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $txt[302] . '" border="0" /></a>', '<br />[', $item['time'], ']</span><br />', empty($item['is_last']) ? '<hr />' : '';

}

$txt[525a] is a text I add in index.french_uft8.php to say "last answer by"

But I don't know how and where define the $item['owner']

I hope you understand me and you'll can help me.

Thanks a lot.

Cedrict

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: sp_recent modification to show the post owner
« Reply #1 on: February 15, 2011, 11:14:21 AM »
I think I understand you perfectly, Cedric.
 
I will try to write in simple English, since I know you are a French speaker.
Thank you for searching for some answers first. You know so much now, I can easily explain the rest.
I will show you how I found out the answer. I hope to make it easy for you to do many more customizations in the future.
 
* 1: What is in $item? Where does $item come from?
Code: (in sp_recent, in PortalBlocks.php) [Select]
$type = 'ssi_recent' . (empty($parameters['type']) ? 'Posts' : 'Topics');
 $items = $type($limit, null, $boards, 'array');
So $items = ssi_recentPosts or else $items = ssi_recentTopics.
Code: (in ssi_recentPosts, in SSI.php) [Select]
return ssi_queryPosts($query_where, $query_where_params, $num_recent, 'm.id_msg DESC', $output_method, $limit_body);
Code: (in ssi_queryPosts, in SSI.php) [Select]
  // Build the array.
  $posts[] = array(
   'id' => $row['id_msg'],
   'board' => array(
    'id' => $row['id_board'],
    'name' => $row['board_name'],
    'href' => $scripturl . '?board=' . $row['id_board'] . '.0',
    'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['board_name'] . '</a>'
   ),
   'topic' => $row['id_topic'],
   'poster' => array(
    'id' => $row['id_member'],
    'name' => $row['poster_name'],
    'href' => empty($row['id_member']) ? '' : $scripturl . '?action=profile;u=' . $row['id_member'],
    'link' => empty($row['id_member']) ? $row['poster_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['poster_name'] . '</a>'
   ),
   'subject' => $row['subject'],
   'short_subject' => shorten_subject($row['subject'], 25),
   'preview' => $smcFunc['strlen']($preview) > 128 ? $smcFunc['substr']($preview, 0, 128) . '...' : $preview,
   'body' => $row['body'],
   'time' => timeformat($row['poster_time']),
   'timestamp' => forum_time(true, $row['poster_time']),
   'href' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . ';topicseen#new',
   'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '" rel="nofollow">' . $row['subject'] . '</a>',
   'new' => !empty($row['is_read']),
   'is_new' => empty($row['is_read']),
   'new_from' => $row['new_from'],
  );
 }
 $smcFunc['db_free_result']($request);
 // Just return it.
 if ($output_method != 'echo' || empty($posts))
  return $posts;

* 2: What do you want from $item?
       You can now see that $item holds everything from $posts (ssi_queryPosts put it there)
       So you can choose from
  • $item['poster']['id']
  • $item['poster']['name']
  • $item['poster']['href']
  • $item['poster']['link']

Now, you choose what to put in youc code.
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Have you tried the SimplePortal documentation?

Offline cedrict

  • Semi Newbie
  • *
  • Posts: 5
  • SMF Version: 1.1.12
  • SP Version: 2.3.3
Re: sp_recent modification to show the post owner
« Reply #2 on: February 16, 2011, 06:09:01 AM »
Thanks so much for your help AngelinaBelle, I understand now what is $item and what I could do with it. I think it is not the good solution to do what I want.

Indeed, $item could'nt have function to declare the name of the owner or first writer of the post.

So, I read SSI.php but I don't find any more solution to resolve my problem. However, in MessageIndex.template.php (a smf file) I found this : ', $topic['first_post']['member']['link'], '  that display the owner of a last topic in a tab.

I don't if I go in the right or wrong way  :0


Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: sp_recent modification to show the post owner
« Reply #3 on: February 16, 2011, 12:19:33 PM »
$item['poster']['link'] should give you the name and link to the profile of the person who posted the post.
 
What is it you want?
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Have you tried the SimplePortal documentation?

Offline cedrict

  • Semi Newbie
  • *
  • Posts: 5
  • SMF Version: 1.1.12
  • SP Version: 2.3.3
Re: sp_recent modification to show the post owner
« Reply #4 on: February 16, 2011, 01:39:09 PM »
$item['poster']['link'] give me the name and the link  to the personn who writed the last post of the topic. I would like to show the name of the person who write the firt post of the topic.

Exemple : sp_recent modification to show the post owner initiated by Cedrict, last reponse by AngelinaBelle on: Today at 11:19:33 AM

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: sp_recent modification to show the post owner
« Reply #5 on: February 16, 2011, 02:41:37 PM »
Yes. This is true. You get the poster of the message, not the poster of the topic.
For that, you would need a new SQL statement -- you would have to write a replacement for one of those SSI functions. It could be done, but not quickly by either one of us.
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Have you tried the SimplePortal documentation?

Offline cedrict

  • Semi Newbie
  • *
  • Posts: 5
  • SMF Version: 1.1.12
  • SP Version: 2.3.3
Re: sp_recent modification to show the post owner
« Reply #6 on: February 16, 2011, 06:15:00 PM »
Well, thanks you for your help :)

I'll try to resolve my problem with lots of test of coding. I'll continue to post that I 'll find or try.

If anybody else have a part of the solution ...  :D

Offline cedrict

  • Semi Newbie
  • *
  • Posts: 5
  • SMF Version: 1.1.12
  • SP Version: 2.3.3
Re: sp_recent modification to show the post owner
« Reply #7 on: February 17, 2011, 09:10:31 AM »
Hi,

After some search, i try to modify ssi_recentTopics in SSI.php, but it seems to not work, the result is a blank page. I don't know where is my mistake.

Code: [Select]
// 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, $ID_MEMBER_STARTED;
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
IFNULL(ml.realName, m.posterName) AS starterName,
FROM ({$db_prefix}messages AS m, {$db_prefix}topics AS t, {$db_prefix}boards AS b, {$db_prefix}messages AS ms)
[b]LEFT JOIN {$db_prefix}members AS ml ON (ml.ID_MEMBER = t.ID_MEMBER_STARTED) [/b]
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 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>'
),
'starter' => array(
'id' => $row['ID_MEMBER_STARTED'],
'name' => $row['starterName'],
'href' => empty($row['ID_MEMBER_STARTED']) ? '' : $scripturl . '?action=profile;u=' . $row['ID_MEMBER_STARTED'],
'link' => empty($row['ID_MEMBER_STARTED']) ? $row['starterName'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER_STARTED'] . '">' . $row['starterName'] . '</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>';
}

« Last Edit: February 17, 2011, 09:24:06 AM by cedrict »

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: sp_recent modification to show the post owner
« Reply #8 on: February 17, 2011, 10:53:35 AM »
I would normally test the SQL statement alone before trying to insert it into a complicated page.
Sometimes, it is convenient to just put it in a SimplePortal php page or block, to see what the outcome is, and how long it takes to run.
And whether it just throws a SQL area.
It looks to me like you have a SQL error from leaving out a comma.
Also, you used m.posterName where you wanted ml.posterName (which wouldn't cause an error)
I have not tested your SQL statement. You should give it a good test, to see if you have any other SQL errors.
 

Code: [Select]
   $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
 
         ,
         IFNULL(ml.realName, ml.posterName) AS starterName,

      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 ml ON (ml.ID_MEMBER = t.ID_MEMBER_STARTED)

         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__);
         
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Have you tried the SimplePortal documentation?

Offline grafitus

  • Comrade
  • *
  • Posts: 1554
  • Gender: Male
  • just looking for own old energy
  • SMF Version: None
  • SP Version: None
Re: sp_recent modification to show the post owner
« Reply #9 on: May 22, 2011, 01:52:29 PM »
Hey, cedrict! Could you do it?
my modsI don't reply support PMs. Please use support forums.