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,026
  • Total Topics: 21,333
  • Online today: 916
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 259
  • Total: 259

Caused by Guest Comments ???

Started by wildenborch, September 15, 2015, 09:21:05 AM

Previous topic - Next topic

0 Members and 3 Guests are viewing this topic.

illori

seems if there are no "new" comments, you receive the wrong error message. this is due to the fact that the text string is defined 2 times.

Line 43: $txt['tp-nocomments'] = 'There are no replies on your comments.'; is the string that should show...

so if we rename that string from tp-nocomments to tp-nocomments2 in the language file and in TPmodules.template.php you will get a better error message...

so with some tweaking i ended up with

case 'showcomments':
echo '
<div style="padding: 4px;">'.$context['TPortal']['pageindex'].'</div>
<table cellpadding="5" cellspacing="1" class="bordercolor" width="100%">
<tr><td colspan="5" class="titlebg">' . $txt['tp-commentnew'] . '</td></tr>
<tr class="catbg">
<td>' . $txt['tp-article'] . '</td>
<td>' . $txt['tp-author'] . '</td>
<td>' . $txt['tp-commenter_time'] . '</td>
<td>' . $txt['tp-commenter'] . '</td>
</tr>';
if(!empty($context['TPortal']['artcomments']['new']))
{
foreach($context['TPortal']['artcomments']['new'] as $mes)
echo '
<tr class="windowbg' , $mes['is_read']==0 ? '3' : '2' , '">
<td><a href="'.$scripturl.'?page='.$mes['page'].'#tp-comment">' . $mes['subject'] . '
' , $mes['is_read']==0 ? ' <img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="" />' : '' , '
</a><div class="smalltext"> ' , $mes['title'] , '</div>
</td>
<td width="10%"><a href="'.$scripturl.'?action=profile;u='.$mes['authorID'].'">' . $mes['author'] . '</a></td>
<td width="25%">' . $mes['time'] . '</td>
<td width="10%"><a href="'.$scripturl.'?action=profile;u='.$mes['member_id'].'">' . $mes['membername'] . '</a></td>
</tr>';

}
else
echo '
<tr><td colspan="5" class="windowbg2">' . $txt['tp-nocomments2'] . '</td></tr>';

echo '
<tr><td colspan="5" class="titlebg" align="right"><a href="' . $scripturl . '?action=tpmod;sa=showcomments;showall">' . $txt['tp-showall'] . '</a></td></tr>';

echo '
</table>
<div style="padding: 4px;">'.$context['TPortal']['pageindex'].'</div>
';
for TPmodules.template.php

not ideal as when on the ;showall action it still shows the link to ;showall but better then nothing.

so that leads to our next bug the linktree on this page goes to the wrong page, so it will redirect you to the board index.

sources/TPmodules.php

Code (find) Select
// construct the pages
$context['TPortal']['pageindex'] = TPageIndex($scripturl.'?action=tpmod;area=showcomments', $tpstart, $check[0], 15);
$context['TPortal']['unreadcomments'] = true;
$context['TPortal']['showall'] = $showall;
$context['TPortal']['subaction'] = 'showcomments';
TPadd_linktree($scripturl.'?action=tpmod;area=showcomments' . ($showall ? ';showall' : '')  , $txt['tp-showcomments']);
loadtemplate('TPmodules');


Code (replace) Select

// construct the pages
$context['TPortal']['pageindex'] = TPageIndex($scripturl.'?action=tpmod;sa=showcomments', $tpstart, $check[0], 15);
$context['TPortal']['unreadcomments'] = true;
$context['TPortal']['showall'] = $showall;
$context['TPortal']['subaction'] = 'showcomments';
TPadd_linktree($scripturl.'?action=tpmod;sa=showcomments' . ($showall ? ';showall' : '')  , $txt['tp-showcomments']);
loadtemplate('TPmodules');

illori

Quote from: wildenborch on September 18, 2015, 10:50:43 AM
Illori,

If you look at the "showcomments" functionality you will probably agree that it looks like that if you click on the article link you will be redirected to that specific comment. However, you are only redirected to the top of the article.

see example http://vanveen-nl.com/index.php?page=149#tp-comment

The link of the comment itself looks like:
http://vanveen-nl.com/index.php?page=151#comment225

To me it looks like something is not working as it should be.
Can you take a look at this?

i have briefly looked into this... it seems that the array that is created to show the comments does not include the id of the comment. without that id the anchor there will always be wrong.

best we can do is change the link from tp-comment to articlecomments that would be the start of the comments on the article.

illori

case 'showcomments':
if(!empty($context['TPortal']['showall'])){
echo '
<div style="padding: 4px;">'.$context['TPortal']['pageindex'].'</div>
<table cellpadding="5" cellspacing="1" class="bordercolor" width="100%">
<tr><td colspan="5" class="titlebg">' . $txt['tp-commentnew'] . '</td></tr>
<tr class="catbg">
<td>' . $txt['tp-article'] . '</td>
<td>' . $txt['tp-author'] . '</td>
<td>' . $txt['tp-commenter_time'] . '</td>
<td>' . $txt['tp-commenter'] . '</td>
</tr>';

if(!empty($context['TPortal']['artcomments']['new']))
{
foreach($context['TPortal']['artcomments']['new'] as $mes)
echo '
<tr class="windowbg' , $mes['is_read']==0 ? '3' : '2' , '">
<td><a href="'.$scripturl.'?page='.$mes['page'].'#tp-comment">' . $mes['subject'] . '
' , $mes['is_read']==0 ? ' <img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="" />' : '' , '
</a><div class="smalltext"> ' , $mes['title'] , '</div>
</td>
<td width="10%"><a href="'.$scripturl.'?action=profile;u='.$mes['authorID'].'">' . $mes['author'] . '</a></td>
<td width="25%">' . $mes['time'] . '</td>
<td width="10%"><a href="'.$scripturl.'?action=profile;u='.$mes['member_id'].'">' . $mes['membername'] . '</a></td>
</tr>';

}
echo '
<tr><td colspan="5" class="titlebg" align="right"><a href="' . $scripturl . '?action=tpmod;sa=showcomments">' . $txt['tp-showcomments'] . '</a></td></tr>';

echo '
</table>
<div style="padding: 4px;">'.$context['TPortal']['pageindex'].'</div>
';
}
else
{
echo '
<div style="padding: 4px;">'.$context['TPortal']['pageindex'].'</div>
<table cellpadding="5" cellspacing="1" class="bordercolor" width="100%">
<tr><td colspan="5" class="titlebg">' . $txt['tp-commentnew'] . '</td></tr>
<tr class="catbg">
<td>' . $txt['tp-article'] . '</td>
<td>' . $txt['tp-author'] . '</td>
<td>' . $txt['tp-commenter_time'] . '</td>
<td>' . $txt['tp-commenter'] . '</td>
</tr>';

if(!empty($context['TPortal']['artcomments']['new']))
{
foreach($context['TPortal']['artcomments']['new'] as $mes)
echo '
<tr class="windowbg' , $mes['is_read']==0 ? '3' : '2' , '">
<td><a href="'.$scripturl.'?page='.$mes['page'].'#tp-comment">' . $mes['subject'] . '
' , $mes['is_read']==0 ? ' <img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="" />' : '' , '
</a><div class="smalltext"> ' , $mes['title'] , '</div>
</td>
<td width="10%"><a href="'.$scripturl.'?action=profile;u='.$mes['authorID'].'">' . $mes['author'] . '</a></td>
<td width="25%">' . $mes['time'] . '</td>
<td width="10%"><a href="'.$scripturl.'?action=profile;u='.$mes['member_id'].'">' . $mes['membername'] . '</a></td>
</tr>';

}
else
echo '
<tr><td colspan="5" class="windowbg2">' . $txt['tp-nocomments2'] . '</td></tr>';
echo '
<tr><td colspan="5" class="titlebg" align="right"><a href="' . $scripturl . '?action=tpmod;sa=showcomments;showall">' . $txt['tp-showall'] . '</a></td></tr>';
echo '
</table>';

}


try this in TPmodules.template.php

it will show the showall link where it should and a showcomment link otherwise.

wildenborch

Hi Illori,

Thanks for this solution. Now it indeed shows the comments (if there are new ones) instead of "Sorry, you are not allowed to comment"
Also the "Show all comments" / "Show latest comments" link is showing!

Best regards,
Fred

illori

great. this should get into the next version of TP.

illori

guest name does not show up in the box for name if the commenter is a guest... minor issue.

wildenborch

Hmm I did not notice that probably because I create a 0 user in members called guest!

illori

guest will always be a user id of 0. just need to find somewhere in the code to tell it that 0 = guest.

you should NEVER create a user with id of 0.

wildenborch

 I have now deleted ID 0 (I thought I already did that earlier...)

wildenborch

Illori,

After some more testing I think the latest comments is not working properly.
It only shows comments posted while you are logged in. Comments posted between a logout and login do not show at all.

Best regards,
Fred

This website is proudly hosted on Crocweb Cloud Website Hosting.