Sitecore (sitecore social connector) - unable to customize content posted to facebook/twitter

1.3k views Asked by At

I've recently installed the sitecore social connector module, and I've placed tweet and like buttons on a page, but I can't seem to control the content either sends to twitter/facebook. The tweet button sends the title of the page as the text to be tweeted, and I'd like to override this.

The facebook like link doesn't seem to do anything. If I go back to the same page, it still shows 1 like, but nothing has appeared on my facebook page.

Any help would be greatly appreciated.

2

There are 2 answers

0
Garnaph On BEST ANSWER

Apologies for the very late reply. I did not realise someone had asked me for a reply.

In the end I found it easier to just use the standard Twitter/Facebook controls. I have since learned that while Sitecore has some useful modules for handling CMS operations, it is often easier on the Content Delivery side to just use whatever web technology is the easiest to implement.

https://dev.twitter.com/web/tweet-button

https://developers.facebook.com/docs/plugins/share-button?locale=en_GB

3
Mark Ursino On

I've decompiled the CodeBehind for the Tweet sublayout and it has this for code:

protected void Page_Load(object sender, EventArgs e)
{
        string text = "var xmlhttp;if (window.XMLHttpRequest){ xmlhttp=new XMLHttpRequest();}else{xmlhttp=new ActiveXObject(\"Microsoft.XMLHTTP\");}xmlhttp.open(\"GET\",url,true);xmlhttp.send();";
        string script = string.Format("<script>twttr.events.bind('tweet', function (event) {{var url = '{2}?itemid={1}&eventname={3}&buttontype=tweet';{4}}});</script>", new object[]
        {
            Sitecore.Context.User.Name.Replace('\\', '.'), 
            Sitecore.Context.Item.ID.ToString(), 
            "/layouts/system/Social/SocialEvents.aspx", 
            base.EventName, 
            text
        });
        this.Page.RegisterStartupScript("tweetsubscribe", script);
}

If you want to change it, you need to de-compile Sitecore.Social.dll which is in the package. Un-zip the package and open the files folder and the DLL will be in the /bin/.

If you don't have a decompiler, ILSpy is a great free one. You can do the same for the other feature, just de-compile and re-build in a local project with changes.

Update: just to clarify, you need to de-compile the current C# in the DLL to make changes to it. You can re-compile into a separate project, you just need to change the Inherits="" in the front-end of the control, e.g.

Instead of this:

Inherits="Sitecore.Social.Sharing.Controls.TweetButton"

Do something like this:

Inherits="MyProject.Sharing.Controls.TweetButton"