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

Recent

Welcome to TinyPortal. Please login or sign up.

Members
Stats
  • Total Posts: 196,163
  • Total Topics: 21,351
  • Online today: 816
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 1
  • Guests: 118
  • Total: 119
  • @rjen

action=tpmod;sa=showcomments;showall

Started by wildenborch, March 05, 2018, 07:33:34 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

wildenborch

Hi,

Is it possible have the result of the folling action:
index.php?action=tpmod;sa=showcomments;showall
showed in a block?

If yes, how?


tino

I can't see a easy way at the moment, you can copy the SQL out and run that independently then style the output how you would like. But there is no one function to call.

wildenborch

Thanks Tino for your reply.
Than I have to use the current functionality.


tino

If you want a most recent comments block. I can add something like that?

wildenborch


tino

Quote from: wildenborch on March 05, 2018, 08:14:27 PM
Oh that would be nice!

Styling like the recent Topics block? I think that is active on the front page of this site.

wildenborch

QuoteStyling like the recent Topics block?

Yes, that would be great. And maybe with the first 30 characters of the comment?

tino

I think this code


// *** Config ***

// Set the maximum number of comments to show.
$limit = 5;
$commlim = 60;

// *** 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.real_name
FROM {db_prefix}tp_articles m
INNER JOIN {db_prefix}tp_variables n ON n.value5 = m.id
INNER 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['real_name'] . '</a>',
'comment' => $row['value2'],
'date' => $row['value4'],
'articleid' => $row['value5'],
'subject' =>  $row['subject'],
'query' => $row['shortname']
);
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="font-size: smaller;">
<span class="tp_month">' , $txt['months_short'][date("n", $details['date'])] , '</span>
<span class="tp_thindivider"></span>
<span class="tp_day">' , date("d",$details['date']) , '</span>
<span class="tp_year"> ' , date("Y",$details['date']) , '</span>
' , ($details['query'] != '' ? '<a href="' . $scripturl . '?page=' . $details['query'] . '">' . $details['subject'] . '</a>' : '<a href="' . $scripturl . '?page=' . $details['articleid'] . '">' . $details['subject'] . '</a>') , '
</div>
<div class="tp_articletext" style="font-size: smaller;">
<div class="tp_details" style="overflow: auto">
<span class="smalltext" style="font-size: xx-small;">' , $details['commenter'] , ' commented :</span><br />
' , $details['comment'] , '
</div>
</div>
</div>';
}

$smcFunc['db_free_result']($request);


From here https://www.tinyportal.net/index.php?topic=31176.0 does similar to what you are looking for?

wildenborch

Yes, this code is indeed what I want.

Must have overlooked this.

Just one small annoyance, the result is showing
 codes:

Fred van Veen commented :
Dank voor je reactie.

Deze foto's zijn genomen met...


wildenborch

Quote

Just one small annoyance, the result is showing
 codes:

Fred van Veen commented :
Dank voor je reactie.

Deze foto's zijn genomen met...

Please ignore this, I cannot reproduce it.

This website is proudly hosted on Crocweb Cloud Website Hosting.