- Posts: 12
COMMUNITY FORUM
[SOLVED] K2 facebook comments
- Chrysanthos
-
Topic Author
- Offline
- New Member
Please Log in or Create an account to join the conversation.
- VietPublic
-
- Offline
- Senior Member
- Posts: 43
Copy ROOT\components\com_k2 to
ROOT\templates\YOUR_TEMPLATE\html\ (create html folder if not exist)
Edit
ROOT\templates\YOUR_TEMPLATE\html\com_k2\templates\default\item.php
After line 673 (before K2_BACK_TO_TOP code) add code
<!-- Facebook Comments -->
<?php if($this->item->params->get('itemComments') && ($this->item->params->get('comments') == '1' || ($this->item->params->get('comments') == '2')) && empty($this->item->event->K2CommentsBlock)): ?>
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
<div class="fb-comments" data-href="<?php $url="".$this->item->absoluteURL; echo $url; ?>" data-width="500" data-num-posts="10"></div>
<?php endif; ?>
Please Log in or Create an account to join the conversation.
- Mariak Bol
-
- Offline
- Senior Member
- Posts: 54
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
Please Log in or Create an account to join the conversation.
- Mariak Bol
-
- Offline
- Senior Member
- Posts: 54
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
Please Log in or Create an account to join the conversation.
- Corneliu Ciornei
-
- Offline
- New Member
- Posts: 1
i have 2 questions...
1.where i have to add api code
2.when i'm inserting the code for facebook comments, will appear both block for comments
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
This tutorial will explain overriding: getk2.org/documentation/tutorials/174-templating-with-k2-and-the-concepts-of-sub-templates
Please Log in or Create an account to join the conversation.
- tai
-
- Offline
- New Member
- Posts: 19
VietPublic wrote: Overide your template ex
Copy ROOT\components\com_k2 to
ROOT\templates\YOUR_TEMPLATE\html\ (create html folder if not exist)
Edit
ROOT\templates\YOUR_TEMPLATE\html\com_k2\templates\default\item.php
After line 673 (before K2_BACK_TO_TOP code) add code
<!-- Facebook Comments --> <?php if($this->item->params->get('itemComments') && ($this->item->params->get('comments') == '1' || ($this->item->params->get('comments') == '2')) && empty($this->item->event->K2CommentsBlock)): ?> <div id="fb-root"></div> <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/all.js#xfbml=1"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk')); </script> <div class="fb-comments" data-href="<?php $url="".$this->item->absoluteURL; echo $url; ?>" data-width="500" data-num-posts="10"></div> <?php endif; ?>
Awesome, it worked, I love you so much !!!!!
Please Log in or Create an account to join the conversation.
- Radu Nefton
-
- Offline
- New Member
- Posts: 18
What changes to this code i have to make so only the facebook comment box shows.
I followed the steps in this topic and both boxes k2 & facebook appears . If i disable the k2 comment it's disappear both of them . Can anyone help me please. :(
Please Log in or Create an account to join the conversation.
- Yiota
-
- Visitor
Please Log in or Create an account to join the conversation.
- Radu Nefton
-
- Offline
- New Member
- Posts: 18
I have atached the item.php to this post can you look at the file and tell me what i`m doing wrong .
Please Log in or Create an account to join the conversation.
- Yiota
-
- Visitor
Thank you.
Please Log in or Create an account to join the conversation.
- Radu Nefton
-
- Offline
- New Member
- Posts: 18
Attachment not found
I changed the exension of the file to .txt
Please Log in or Create an account to join the conversation.
- Yiota
-
- Visitor
<div class="itemComments">
<?php if($this->item->params->get('commentsFormPosition')=='above' && $this->item->params->get('itemComments') && !JRequest::getInt('print') && ($this->item->params->get('comments') == '1' || ($this->item->params->get('comments') == '2' && K2HelperPermissions::canAddComment($this->item->catid)))): ?>
<!-- Item comments form -->
<div class="itemCommentsForm">
<?php echo $this->loadTemplate('comments_form'); ?>
</div>
<?php endif; ?>
<?php if($this->item->numOfComments>0 && $this->item->params->get('itemComments') && ($this->item->params->get('comments') == '1' || ($this->item->params->get('comments') == '2'))): ?>
<!-- Item user comments -->
<h3 class="itemCommentsCounter">
<span><?php echo $this->item->numOfComments; ?></span> <?php echo ($this->item->numOfComments>1) ? JText::_('K2_COMMENTS') : JText::_('K2_COMMENT'); ?>
</h3>
<ul class="itemCommentsList">
<?php foreach ($this->item->comments as $key=>$comment): ?>
<li class="<?php echo ($key%2) ? "odd" : "even"; echo (!$this->item->created_by_alias && $comment->userID==$this->item->created_by) ? " authorResponse" : ""; echo($comment->published) ? '':' unpublishedComment'; ?>">
<span class="commentLink">
<a href="<?php echo $this->item->link; ?>#comment<?php echo $comment->id; ?>" name="comment<?php echo $comment->id; ?>" id="comment<?php echo $comment->id; ?>">
<?php echo JText::_('K2_COMMENT_LINK'); ?>
</a>
</span>
<?php if($comment->userImage): ?>
<img src="<?php echo $comment->userImage; ?>" alt="<?php echo JFilterOutput::cleanText($comment->userName); ?>" width="<?php echo $this->item->params->get('commenterImgWidth'); ?>" />
<?php endif; ?>
<span class="commentDate">
<?php echo JHTML::_('date', $comment->commentDate, JText::_('K2_DATE_FORMAT_LC2')); ?>
</span>
<span class="commentAuthorName">
<?php echo JText::_('K2_POSTED_BY'); ?>
<?php if(!empty($comment->userLink)): ?>
<a href="<?php echo JFilterOutput::cleanText($comment->userLink); ?>" title="<?php echo JFilterOutput::cleanText($comment->userName); ?>" target="_blank" rel="nofollow">
<?php echo $comment->userName; ?>
</a>
<?php else: ?>
<?php echo $comment->userName; ?>
<?php endif; ?>
</span>
<p><?php echo $comment->commentText; ?></p>
<?php if($this->inlineCommentsModeration || ($comment->published && ($this->params->get('commentsReporting')=='1' || ($this->params->get('commentsReporting')=='2' && !$this->user->guest)))): ?>
<span class="commentToolbar">
<?php if($this->inlineCommentsModeration): ?>
<?php if(!$comment->published): ?>
<a class="commentApproveLink" href="<?php echo JRoute::_('index.php?option=com_k2&view=comments&task=publish&commentID='.$comment->id.'&format=raw')?>"><?php echo JText::_('K2_APPROVE')?></a>
<?php endif; ?>
<a class="commentRemoveLink" href="<?php echo JRoute::_('index.php?option=com_k2&view=comments&task=remove&commentID='.$comment->id.'&format=raw')?>"><?php echo JText::_('K2_REMOVE')?></a>
<?php endif; ?>
<?php if($comment->published && ($this->params->get('commentsReporting')=='1' || ($this->params->get('commentsReporting')=='2' && !$this->user->guest))): ?>
<a class="modal" rel="{handler:'iframe',size:{x:560,y:480}}" href="<?php echo JRoute::_('index.php?option=com_k2&view=comments&task=report&commentID='.$comment->id)?>"><?php echo JText::_('K2_REPORT')?></a>
<?php endif; ?>
<?php if($comment->reportUserLink): ?>
<a class="k2ReportUserButton" href="<?php echo $comment->reportUserLink; ?>"><?php echo JText::_('K2_FLAG_AS_SPAMMER'); ?></a>
<?php endif; ?>
</span>
<?php endif; ?>
<div class="clr"></div>
</li>
<?php endforeach; ?>
</ul>
<div class="itemCommentsPagination">
<?php echo $this->pagination->getPagesLinks(); ?>
<div class="clr"></div>
</div>
<?php endif; ?>
<?php if($this->item->params->get('commentsFormPosition')=='below' && $this->item->params->get('itemComments') && !JRequest::getInt('print') && ($this->item->params->get('comments') == '1' || ($this->item->params->get('comments') == '2' && K2HelperPermissions::canAddComment($this->item->catid)))): ?>
<!-- Item comments form -->
<div class="itemCommentsForm">
<?php echo $this->loadTemplate('comments_form'); ?>
</div>
<?php endif; ?>
<?php $user = JFactory::getUser(); if ($this->item->params->get('comments') == '2' && $user->guest): ?>
<div><?php echo JText::_('K2_LOGIN_TO_POST_COMMENTS'); ?></div>
<?php endif; ?>
</div>
with this one:
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
<div class="fb-comments" data-href="<?php $url="".$this->item->absoluteURL; echo $url; ?>" data-width="500" data-num-posts="10"></div>
not keep them both in your item.
Please Log in or Create an account to join the conversation.
- Radu Nefton
-
- Offline
- New Member
- Posts: 18
God bless you .
I want to ask you another thing , when i copied the com_k2 from root/componet to templates/my-template/html/com_k2/templates/default all the item style(view) has changed. How can i change this style back .
Please Log in or Create an account to join the conversation.
- Yiota
-
- Visitor
templates/my-template/html/com_k2/default rather than templates/my-template/html/com_k2/templates/default
Try that and let me know.
Please Log in or Create an account to join the conversation.
- Radu Nefton
-
- Offline
- New Member
- Posts: 18
Please Log in or Create an account to join the conversation.
- Radu Nefton
-
- Offline
- New Member
- Posts: 18
generic.php
generic_search.php
index.html
profile.php
register.php
and moved them up one level .
But nothing chaged .
Please Log in or Create an account to join the conversation.
- Yiota
-
- Visitor
default (folder)
generic.php
generic_search.php
index.html
profile.php
register.php
Please Log in or Create an account to join the conversation.