By Niccolo Angeli on Sunday, 11 November 2018
Posted in Technical Issues
Likes 0
Views 778
Votes 0
Hi guys,
I need a suggestion.
I have inserted a "comments" link in my articles info block (where author, date, views etc. info is) along with the total comments number.
The problem is that if I disable Komento in a single article, the link still shows with an apparently random number of comments.

Here is the code I am using to show this link, if you could suggest a hack to hide the link (or at least show a default "0 comments" text) that would be great.
Thank you!

Here is the code I am using



<?php
// call Komento comment model
$commentsModel = KT::model('Comments');
$commentCount = $commentsModel->getTotal('com_content', $this->item->id);
?>


as you see below I show the comments link if the publish date is displaied, not a very elegant solution... works fine in many cases but not when Komento is disabled for a single article where the publish date is also disaplied


<?php if ($displayData['params']->get('show_publish_date')) : ?>
<?php echo $this->sublayout('publish_date', $displayData); ?>
<!-- Render Komento comments single article page -->
<dd>
<i class="fa fa-fw fa-comments-o"></i> <a href="#comments"><span class="commentCounter" data-kt-counter><?php echo $commentCount; ?> </span><?php echo JText::_('COM_KOMENTO_COMMENTS'); ?></a>
</dd>
<!-- Render Komento comments on single article page - end -->
<?php endif; ?>
Hi Niccolo,

Basically you want to hide the comment count (from the code you've make above) if you disable the settings>comments>integrations>komento ( https://www.screencast.com/t/fAXS1quK )yes? I think you need to alter the condition to display the comment count to use the param from this setting.
Can you try to alter your code above to use the code below and see how it goes?

<?php if ($this->entryParams->get('comment_komento', true)) { ?>
<?php echo $this->sublayout('publish_date', $displayData); ?>
<!-- Render Komento comments single article page -->
<dd>
<i class="fa fa-fw fa-comments-o"></i> <a href="#comments"><span class="commentCounter" data-kt-counter><?php echo $commentCount; ?> </span><?php echo JText::_('COM_KOMENTO_COMMENTS'); ?></a>
</dd>
<!-- Render Komento comments on single article page - end -->
<?php endif; ?>


You are suggest to backup the file that you want to customize just for precaution step
·
Monday, 12 November 2018 10:53
·
0 Likes
·
0 Votes
·
0 Comments
·
Basically you want to hide the comment count (from the code you've make above) if you disable the settings>comments>integrations>komento ( https://www.screencast.com/t/fAXS1quK )yes?

I want to hide the coment count when using the tag {KomentoDisable} inside a single article

the code you suggested causes an error though...

"sintax error, unexpected endif"

I attach the info_block.php, if you want to test with it
it goes in
/templates/your-template/html/layouts/joomla/content

edit starts at line 50

thanks
·
Monday, 12 November 2018 17:00
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi Niccolo,

Sorry for my misunderstanding, can you try the file that I've attached below and see how it goes?

You are suggest to backup the file that you want to replace just for precaution step
·
Tuesday, 13 November 2018 11:36
·
0 Likes
·
0 Votes
·
0 Comments
·
Thank you.
Now it works but the article publish date get hidden also.

I tried to change the code you suggested like this


<?php if ($displayData['params']->get('show_publish_date')) : ?>
<?php echo $this->sublayout('publish_date', $displayData); ?>
<?php endif; ?>

<?php if (!$komentoDisable) : ?>

<!-- Render Komento comments single article page -->
<dd>
<i class="fa fa-fw fa-comments-o"></i> <a href="#comments"><span class="commentCounter" data-kt-counter><?php echo $commentCount; ?> </span><?php echo JText::_('COM_KOMENTO_COMMENTS'); ?></a>
</dd>
<!-- Render Komento comments on single article page - end -->
<?php endif; ?>


previously it was


<?php if (!$komentoDisable) : ?>
<?php echo $this->sublayout('publish_date', $displayData); ?>
<!-- Render Komento comments single article page -->
<dd>
<i class="fa fa-fw fa-comments-o"></i> <a href="#comments"><span class="commentCounter" data-kt-counter><?php echo $commentCount; ?> </span><?php echo JText::_('COM_KOMENTO_COMMENTS'); ?></a>
</dd>
<!-- Render Komento comments on single article page - end -->
<?php endif; ?>


but the publish date is still being hidden along with the comments count (you may check here https://accademiainfinita.it/blog/44-notizie/1086-progetto-coemm-quid-aggiornamenti-2018

any idea why this is happening?

What I want to achieve is:

IF the publish date is showed > show comments count also
IF the publish date is hidden > hide the comment count also
IF "Komentodisable" is present > hide the comments count (but still show the publish date if it is set as showed)

Thanks
·
Tuesday, 13 November 2018 18:07
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi Niccolo,

Seems like your code that you've changed is already correct where you separate the display according to the setting (I've also tested in my local instance)
Can you double check the article settings and menu (if you have menu for the view) have been enable. http://take.ms/VyeRv
·
Tuesday, 13 November 2018 19:11
·
0 Likes
·
0 Votes
·
0 Comments
·
Global settings is set to HIDE but menu item is set to SHOW; infact other articles from the same category have the publish date showing normally.
As soon as I delete {KomentoDisable} from teh article body, the publish date shows again.
When I paste it back, it is hidden again. Strange...
I have cleared Joomla and browser cache, but it doesn't seem to be related to that.

I attach the info_block.php file I am testing with right now
·
Tuesday, 13 November 2018 19:47
·
0 Likes
·
0 Votes
·
0 Comments
·
This is strange indeed, I've use the latest file that you've provided above seems works fine though.
May I know do you have customize any other file? Perhaps, can you provide us with your backend and FTP access so that I can a better view on this

You can edit your first post to include the information needed or just include your site's access once at http://stackideas.com/dashboard/site rather than needing to keep adding them in your replies
·
Wednesday, 14 November 2018 12:26
·
0 Likes
·
0 Votes
·
0 Comments
·
Yes, strange indeed!
I have updated the main post with access details and links for testing
the access details are on a test site I created where the issue is visible too, so feel free to mess around (just keep the site offline after testing).

Thank you, I really appreciate you looking into this
·
Wednesday, 14 November 2018 22:11
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi Niccolo,

Seems like the code in your test site still using old code, I've update it to separate the publish date and comment link accordingly.
It is suppose to show like this yes? http://take.ms/Q43fGf
·
Thursday, 15 November 2018 11:41
·
0 Likes
·
0 Votes
·
0 Comments
·
Thanks a lot! I must have made mistakes copying the files in an out of the server then...
·
Thursday, 15 November 2018 19:52
·
0 Likes
·
0 Votes
·
0 Comments
·
You are most welcome Niccolo

Just for your information, I have locked and marked this thread as resolved to avoid confusions in the future. Please start a new thread if you have any other issue in the future so it will be easier for us to manage your inquiries.

Thanks for understanding
·
Friday, 16 November 2018 10:07
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post