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

Recent

Welcome to TinyPortal. Please login or sign up.

March 28, 2024, 12:42:50 PM

Login with username, password and session length
Members
Stats
  • Total Posts: 195,104
  • Total Topics: 21,212
  • Online today: 212
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 67
  • Total: 67

[Block] Recent comments on articles.

Started by freddy888, October 16, 2009, 05:42:31 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

wildenborch

Yes this is perfect!

Thank you very much @rjen and Tino!

And for future support requests I shall mention:

"Well it's not so important ....
If - in the future - you have some time to look into it the code it would be a nice .....

;D

wildenborch

Hi Arjan, Tino,

I assume that with TP version 2 the code for showing the comments is no longer working?

// *** Config ***
// Set the maximum number of comments to show.
$limit = 25;
// Set the maximum number of characters per comment to show.
$commlim = 90;
// *** End Of Config ***

// Now the code..
global $scripturl, $db_prefix, $smcFunc, $txt;

$request = $smcFunc['db_query']('', '
SELECT n.value2, n.value3, n.value4, n.value5, m.subject, m.author_id, m.author, m.shortname, o.member_name AS member_name
FROM {db_prefix}tp_articles m
      LEFT OUTER JOIN {db_prefix}tp_variables n ON n.value5 = m.id
      LEFT OUTER JOIN {db_prefix}members o ON n.value3 = o.id_member
WHERE n.type = {string:type}
ORDER BY n.value4 DESC
LIMIT {int:limit}',
array('type' => 'article_comment', 'limit' => $limit)
);

while ($row = $smcFunc['db_fetch_assoc']($request))
{
// Let's make these variable a little more readable...
$details = array(
'commenter' => '<a href="' . $scripturl . '?action=profile;u=' . $row['value3'] . '">' . $row['member_name'] . '</a>',
'comment' => $row['value2'],
'date' => $row['value4'],
'articleid' => $row['value5'],
'subject' =>  $row['subject'],
'query' => $row['shortname'],
        'id' => $row['value3']
);
if (strlen(html_entity_decode($details['comment'])) > $commlim)
             $details['comment'] = htmlentities(substr(html_entity_decode($details['comment']), 0, ($commlim-3)) . '...');
// Build the output...
echo '
<div class="tborder tp_article_frame">
<div class="catbg tp_subject" style="padding: 7px 0px 7px 0px;">

' , ($details['query'] != '' ? '<a href="' . $scripturl . '?page=' . $details['query'] . '">' . $details['subject'] . '</a>' : '<a href="' . $scripturl . '?page=' . $details['articleid'] . '">' . $details['subject'] . '</a>') , '
</div><span style="font:smalltext;">
<div class="">On
<span class="tp_thindivider"></span>
<span>' , date("l",$details['date']) , '</span>
<span>' , date("d",$details['date']) , '</span>
<span>' , $txt['months_short'][date("n", $details['date'])] , '</span>
<span> ' , date("Y",$details['date']) , '</span>
<span> ' , date("H:i:s",$details['date']) , '</span>
<span><b> ' , (($details['id'] > 0) ? $details['commenter']  :  $txt['tp-guest']) , '</b></span>

<span class="">commented: </B></span>

<div class="" style="color: #330000; font-size: 16px""><br>

' ,$details['comment'], '

</div>
<br></div>
</div>';
}
$smcFunc['db_free_result']($request);


What should be changed to make it working again?



@rjen

Running Latest TP on SMF2.1 at: www.fjr-club.nl

tino

Quote from: @rjen on March 15, 2021, 04:20:01 PM
What makes you assume that?

Probably the fact I moved the article comments to their own table. The table is now tp_comments and is mapped as per this change.

https://github.com/Tinyportal/TinyPortal/blob/7b6c194a411f3187004f6c5a50b41a41a751214d/install.php#L985

So all the value# need to be changed to their respective new column name and the block updated accordingly.

wildenborch

And I assume that this commmand is affected by this change as well?

index.php?action=tportal;sa=showcomments;showall

this was

index.php?action=tpmod;sa=showcomments;showall

tino

Yes tpmod was changed tportal in a lot of instances. Or if it was an admin area it's tpadmin now.

wildenborch

But have you an idea why index.php?action=tportal;sa=showcomments;showall isn't working (not showing any comment)?

Fred

tino

Quote from: wildenborch on March 15, 2021, 10:28:24 PM
But have you an idea why index.php?action=tportal;sa=showcomments;showall isn't working (not showing any comment)?

Fred

Looking at the code. It seems it was missed in the updates. Not even sure how it's actually called atm, other than manually.

wildenborch

Hi Tino,

I really tried it but I really don't know what I'm doing and what to change or delete.

If you have some time, would you mind changing the script?

Fred 

tino

I'll look at it this weekend. The comments one will be a new patch release, probably 2.0.2. I don't know of any other bugs in that one so it might be a while before it's officially released, you can take the earlier release mind.