TinyPortal

Development => Support => Topic started by: wildenborch on March 05, 2018, 07:33:34 PM

Title: action=tpmod;sa=showcomments;showall
Post by: wildenborch on March 05, 2018, 07:33:34 PM
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?

Title: Re: action=tpmod;sa=showcomments;showall
Post by: tino on March 05, 2018, 08:01:18 PM
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.
Title: Re: action=tpmod;sa=showcomments;showall
Post by: wildenborch on March 05, 2018, 08:05:04 PM
Thanks Tino for your reply.
Than I have to use the current functionality.

Title: Re: action=tpmod;sa=showcomments;showall
Post by: tino on March 05, 2018, 08:07:01 PM
If you want a most recent comments block. I can add something like that?
Title: Re: action=tpmod;sa=showcomments;showall
Post by: wildenborch on March 05, 2018, 08:14:27 PM
Oh that would be nice!
Title: Re: action=tpmod;sa=showcomments;showall
Post by: tino on March 05, 2018, 08:26:18 PM
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.
Title: Re: action=tpmod;sa=showcomments;showall
Post by: wildenborch on March 05, 2018, 08:29:29 PM
QuoteStyling like the recent Topics block?

Yes, that would be great. And maybe with the first 30 characters of the comment?
Title: Re: action=tpmod;sa=showcomments;showall
Post by: tino on March 06, 2018, 07:19:15 PM
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?
Title: Re: action=tpmod;sa=showcomments;showall
Post by: wildenborch on March 06, 2018, 10:11:40 PM
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...

Title: Re: action=tpmod;sa=showcomments;showall
Post by: wildenborch on March 07, 2018, 07:04:14 AM
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.
Title: Re: action=tpmod;sa=showcomments;showall
Post by: tino on March 07, 2018, 07:06:50 PM
That code block ok for you then? I'll look to add it to the core functionality if it is.
Title: Re: action=tpmod;sa=showcomments;showall
Post by: wildenborch on March 07, 2018, 07:16:42 PM
Yes for me this one is ok!