Jump to content

Adding facebook discussion to knowledgebase


bytedisorder

Recommended Posts

I wanted to add facebook discussion to my knowedgebase articles so I wrote this up:

 

{literal}
<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>
{/literal}
<div class="fb-like" data-href="{$systemurl}{if $seofriendlyurls}knowledgebase/{$kbarticle.id|strip_tags}/{$kbarticle.urlfriendlytitle}.html{else}knowledgebase.php?action=displayarticle&id={$kbarticle.id}{/if}" data-send="true" data-width="590" data-show-faces="true" data-action="recommend"></div>
<br /><br />
{$kbarticle.id}
{literal}
<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>
{/literal}
<fb:comments href="{$systemurl}{if $seofriendlyurls}knowledgebase/{$kbarticle.id}/{$kbarticle.urlfriendlytitle}.html{else}knowledgebase.php?action=displayarticle&id={$kbarticle.id}{/if}" num_posts="5" width="590"></fb:comments>

 

Unfortunately what that gives me is links to the last article on the read more not the urls for the knowledgebase page. Does anybody have a solution for this?

Link to comment
Share on other sites

Got it, this works!

 

{literal}
<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>
{/literal}
<div class="fb-like" data-href="{$smarty.server.HTTP_HOST}{$smarty.server.REQUEST_URI}" data-send="true" data-width="590" data-show-faces="true" data-action="recommend"></div>
<br /><br />
{literal}
<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>
{/literal}
<fb:comments href="{$smarty.server.HTTP_HOST}{$smarty.server.REQUEST_URI}" num_posts="5" width="590"></fb:comments>

Link to comment
Share on other sites

  • 6 months later...
Got it, this works!

 

{literal}
<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>
{/literal}
<div class="fb-like" data-href="{$smarty.server.HTTP_HOST}{$smarty.server.REQUEST_URI}" data-send="true" data-width="590" data-show-faces="true" data-action="recommend"></div>
<br /><br />
{literal}
<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>
{/literal}
<fb:comments href="{$smarty.server.HTTP_HOST}{$smarty.server.REQUEST_URI}" num_posts="5" width="590"></fb:comments>

 

Error with https server

 

I changed : {$smarty.server.HTTPS_HOST}{$smarty.server.REQUEST_URI} for like, it's working ..

 

I changed : {$smarty.server.HTTPS_HOST}{$smarty.server.REQUEST_URI} for comment, get an error.

 

"The comments plugin requires an href parameter."

 

Please help me fix this problem.

 

Thank's

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated