Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > Facebook Like Button View modes: 
User avatar
Member
Member
nabraham-tibus - 3/15/2011 6:08:52 AM
   
Facebook Like Button
Hi

I would like to add facebook like button on the header of the page, i used the following line of code, but it shows an erroe, says GetAbsoluteUrl is not defined. Can i miss anything from the code? Any ideas.

<iframe src="http://www.facebook.com/plugins/like.php?href=<%# Server.UrlEncode(GetAbsoluteUrl(GetDocumentUrl())) %>&layout=standard&show_faces=true&width=450&action=like&colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden;"></iframe>

Thanks
Nibu

User avatar
Member
Member
kentico_michal - 3/15/2011 8:36:44 AM
   
RE:Facebook Like Button
Hi Nibu,

Could you please let me know where exactly did you add this code? We have not encountered with any error message.

Could you please post here the complete error message or related log from Event log (Site manager -> Administration -> Event log)?

Moreover, which version of Kentico CMS are you using?

Thank you in advance.

Best regards,
Michal Legen

User avatar
Member
Member
nabraham-tibus - 3/15/2011 8:56:44 AM
   
RE:Facebook Like Button
Hi Michal

I added the code in my user control page, my version is 5.5

Can I use anu namespace refrence in code behind page? (Currently I used reference as 'using CMS.PortalControls;')

The error message is below :
The name 'GetAbsoluteUrl' does not exist in the current context

Thanks
Nibu

User avatar
Member
Member
kentico_michal - 3/16/2011 4:28:40 AM
   
RE:Facebook Like Button
Hi Nibu,

Could you please try to use following code which uses ResolveUrl instead of the GetDocumentUrl and uses the CMSAbstractTransformation object to invoke the GetAbsoluteUrl method:


protected void Page_Load(object sender, EventArgs e)
{
CMS.Controls.CMSAbstractTransformation at = new CMS.Controls.CMSAbstractTransformation();
System.Text.StringBuilder builder = new System.Text.StringBuilder();
builder.Append("<iframe src=\"http://www.facebook.com/plugins/like.php?href=");
builder.Append(Server.UrlEncode(at.GetAbsoluteUrl(ResolveUrl(CMS.CMSHelper.CMSContext.GetUrl(CMS.CMSHelper.CMSContext.CurrentDocument.NodeAliasPath, CMS.CMSHelper.CMSContext.CurrentDocument.DocumentUrlPath)))));
builder.Append("&layout=standard&show_faces=true&width=450&action=like&colorscheme=light\" scrolling=\"no\" frameborder=\"0\" allowTransparency=\"true\" style=\"border:none; overflow:hidden;\"></iframe>");

ltl.Text = builder.ToString();
ltl.Mode = LiteralMode.PassThrough;
}


ltl is the ID of standard asp:Literal control.


Best regards,
Michal Legen

User avatar
Member
Member
nabraham-tibus - 3/17/2011 9:44:00 AM
   
RE:Facebook Like Button
Hi Michal

It works fine, thanks for the helps.

By, Nibu

User avatar
Member
Member
brian-sparkventure - 4/21/2011 8:06:40 PM
   
RE:Facebook Like Button
I'm trying to do the same thing, but not in a asp.net control but in a editable text web part. When I put the script using source the asp.net characters get mangled. Here is an example of what happens:

<fb:like font="" href="<%# GetDocumentUrl() %>" show_faces="true"></fb:like>


Should i be using a different web part for these types of scripts that won't have this behavior?


User avatar
Member
Member
kentico_michal - 4/22/2011 2:46:02 AM
   
RE:Facebook Like Button
Hi,

You can find a short guide on how to implement the facebook like button on our blog. It should work in Editable text web part so could you please try to use the script from the blog?


Best regards,
Michal Legen

User avatar
Member
Member
brian-sparkventure - 4/23/2011 6:23:42 PM
   
RE:Facebook Like Button
It tried it out the code you sent, but it looks like the text in the text web part is not being complied (although the URLEncode didn't show up in the browser) on the server side so ASP.NET is not interpreting the tags. So, I'm not really sure what's going on

Here's the output in the browser.

<fb:like class=" fb_edge_widget_with_comment fb_iframe_widget" href="<%# GetDocumentUrl() %>" show_faces="true" width="450" font="tahoma">

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 4/26/2011 2:22:59 AM
   
RE:Facebook Like Button
Hi,

I tried to insert following code into editable text webpart. I switched to the Source of editable text webpart first and inserted the code:


<iframe src="http://www.facebook.com/plugins/like.php?href=<%# Server.UrlEncode(GetAbsoluteUrl(GetDocumentUrl())) %>&layout=standard&show_faces=true&width=450&action=like&colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden;"></iframe>


It was resolved correctly.

Could you please check if you have copied/pasted the whole code correctly?
Which version of the Kentico CMS are you using?

Best regards,
Ivana Tomanickova

User avatar
Member
Member
info-business-it - 6/2/2011 7:15:46 AM
   
RE:Facebook Like Button
Hi Ivana,
I have insert your code on a editable webpart (like news), it's work but not correctly!!

I mean, in the view of the HTML code of the page does not appear in the following code


<iframe src="http://www.facebook.com/plugins/like.php?href=http://www.mysite.com ... ...


but the original code, with the FB to not know the page.


Best regards,
Christos

User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 6/2/2011 7:41:01 AM
   
RE:Facebook Like Button
Hello,

Could you please post the exact code which is rendered? You can of course change the domain name.

Best regards,
Boris Pocatko

User avatar
Member
Member
info-business-it - 6/2/2011 7:47:58 AM
   
RE:Facebook Like Button
Hi,
this is the Html code from the site

<br />
<iframe src="http://www.facebook.com/plugins/like.php?href=&lt;%# Server.UrlEncode(GetAbsoluteUrl(GetDocumentUrl())) %&gt;&layout=standard&show_faces=true&width=450&action=like&colorscheme=light" frameborder="0" allowtransparency="allowtransparency" scrolling="no" style="border-bottom: medium none; border-left: medium none; width: 308px; height: 41px; overflow: hidden; border-top: medium none; border-right: medium none"></iframe></p>

User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 6/2/2011 8:29:51 AM
   
RE:Facebook Like Button
Hello,

I've checked Ivanas code once more and it's working like a charm. I've made some screenshots of this, maybe you are missing a step. The first image shows, ho I've added the code to an Editable region. The second image shows what I am getting, if I save the changes and switch to the non-source view. And at last there is the site in the live mode together with the correctly generated code.

Best regards,
Boris Pocatko

User avatar
Member
Member
info-business-it - 6/3/2011 2:25:27 AM
   
RE:Facebook Like Button
Hello Boris,
last Night I make many test with Ivanas code and the FB like button.
The result.
Ivanas code don't work correctly on a Editable region, the URL will not be generate. We can see the FB like logo on the website, but if you try to "LIKE" -- wrong.

The code works correct, if the added in a transfomation.

To work correctly Ivanas code on a Editable region we must change manually the folloving code
<%# Server.UrlEncode(GetAbsoluteUrl(GetDocumentUrl())) %>
with the page URL.

Best regards

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 6/4/2011 1:54:56 AM
   
RE:Facebook Like Button
Hi,

Could you please tell us what version/hotfix of Kentico you are using?

Could you please share source code of your editable region content? (please insert it using code button (the forth from the left side) so it will be displayed as a code.

Best regards,
Ivana Tomanickova

User avatar
Member
Member
info-business-it - 6/5/2011 4:38:11 PM
   
RE:Facebook Like Button
Hi,
My version/hotfix is 5.5 Build: 5.5.3999

The code from my editable region is

<iframe src="http://www.facebook.com/plugins/like.php?href=<%# Server.UrlEncode(GetAbsoluteUrl(GetDocumentUrl())) %>&layout=standard&show_faces=false&width=350&action=like&colorscheme=light" frameborder="0" scrolling="no" style="width: 279px; height: 38px"></iframe>


You can see this live "http://www.business-it.gr/News/emporiko.aspx" the first like button from the editable region works not correctly, the second button insert on the CMS.News.NewsDetail transformation works fine

<div class="newsItemDetail">
<h1><%# Eval("NewsTitle") %></h1>
<div class="NewsSummary">
<%# IfEmpty(Eval("NewsTeaser"), "", GetImage("NewsTeaser")) %>
<div class="NewsContent">
<div class="Date"><%# GetDateTime("NewsReleaseDate", "d") %></div>
<%# Eval("NewsSummary") %>
</div>
<div class="Clearer"> </div>
</div>
<div class="NewsBody">
<%# Eval("NewsText") %>
</div>
<table style="width: 35%">
<tbody>
<tr>
<td style="width: 58px"><iframe src="http://www.facebook.com/plugins/like.php?href=<%# Server.UrlEncode(GetAbsoluteUrl(GetDocumentUrl())) %>&layout=standard&show_faces=false&width=350&action=like&colorscheme=light" frameborder="0" scrolling="no" style="width: 279px; height: 38px"></iframe></td>
<td style="width: 115px" valign="top"><a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" style="vertical-align: top;">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></td>
</tr>
</tbody>
</table></div>

User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 6/6/2011 3:42:11 AM
   
RE:Facebook Like Button
Hello,

Yes, you are right. I am sorry for the confusion. After I click on the button an error is displayed. I've checked with our developer and this code can be added either in a transformation as you suggested at first or you can create a custom macro which would generate you the given code. For more information about writing macros please check our documentation. The macro can be then used in e.g. the Static text web part.

Best regards,
Boris Pocatko

User avatar
Member
Member
Willy - 7/22/2011 3:37:43 AM
   
RE:Facebook Like Button
I tried the code for facebook like however, in firefox it shows nothing. In IE and Chrome it works fine.

Below are the link to the screenshots; (facebook like is located at the bottom left with red border)

FF: http://ScrnSht.com/exnhgu
Chrome/IE: http://ScrnSht.com/xrhloo

Regards,
Willy

User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 7/25/2011 5:41:37 AM
   
RE:Facebook Like Button
Hello,

Could you please let me know where you are inserting the code and exactly which code you are using? I've tried the code below and it seems to work on all mentioned browsers (FF 4, IE9, Chrome):

<iframe src="http://www.facebook.com/plugins/like.php?href=<%# Server.UrlEncode(GetAbsoluteUrl(GetDocumentUrl())) %>&layout=standard&show_faces=false&width=350&action=like&colorscheme=light" frameborder="0" scrolling="no" style="width: 279px; height: 38px"></iframe>

Best regards,
Boris Pocatko

User avatar
Member
Member
EvanchikM-asme - 8/2/2011 3:55:33 PM
   
RE:Facebook Like Button
We're trying to get the facebook like button integrated on our site as well...and while we seem to have it working on our sandbox, it's not showing up in IE7, which is our default browser.

Any ideas how to get this to work?

User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 8/3/2011 9:01:41 AM
   
RE:Facebook Like Button
Hello,

I've tried the same setup in a transformation and it is working just fine.

Best regards,
Boris Pocatko