Thursday, September 03, 2009

Adding Google Friend Connect to Blogengine.net Blog

Today i am shifting my blog from BlogSpot to custom domain, so i will be doing a series of post in all the hassles i have to face during this exercise and share my experience with you, so that any one else in plans of shifting the blog to custom domain and also the blog code being open source, should not face the same problems as i am facing.

Smallworkarounds was known for its unique look and feel and various plugins customized in the heart of Google’s blogger.Still the new blog is not even close to the look and feel of the current BlogSpot version but its OK for now i will be rewriting the whole code myself within few days as i get time from my busy schedule.

I will be writing mostly on how to transfer each module you see on Smallworkarounds on blogspot to www.smallworkarounds.com.

For today i will be discussing how to integrate Google’s Friend Connect into BlogEngine.net.

First of all let me tell you why i chose blogengine.net, the obvious reason is that i have already worked on blogengine.net and i am familier with most of its code and I can do tweaks to it’s code in no time.

Secondly what i found after googling was that blogengine.net is the leader in the open source blog engines built in .net. Although there are few other competitors but again all comes to personal choice you can use anyone of the other products out there.

I faced few issues with blogengine.net on Godaddy but i will be dealing those issues in the upcoming posts.

So let’s begin the journey from what i am currently doing and leave the  rest for future.

Currently i have all my posts imported from blogger to blogengine.net  with some minor errors which i am tweaking daily.

In my blogspot blog i was having a Google Friend Connect toolbar which used to pop up at the bottom, but now the question is how to get the same popup bar with same followers in your blogengine.net blog with your custom domain.

Googling a bit lead me to this post by Mayank Raichura , he has done all the hard work but what he has implemented is a little different from what i wanted.

You can download his sample from here

Hi implementation lets you to have google friend connect only inside the posts pages not on all the pages as this is clear from his code i modified his code a bit and everything then worked just fine for me.

 public void CreateFriendConnectBar(ServingEventArgs e)
    {
        settings = ExtensionManager.GetSettings(GetType().Name);

        //Settings should be retrieved after this...
        string sb_Site_ID = settings.GetSingleValue("Site_ID").ToLower();
        string sb_Div_Tag_ID = settings.GetSingleValue("Div_Tag_ID").ToLower();
        string sb_Scope_of_Social_Bar = "SITE";        
        bool sb_Allow_Anonymous_Post = bool.Parse(settings.GetSingleValue("Allow_Anonymous_Post").ToLower());

        //End Settings Retrieval
        e.Body += "\n<!-- Google_Friend_Connects_Social_Bar extension by Mayank Raichura -->\n";
        e.Body += BuildHTML(sb_Site_ID, sb_Div_Tag_ID, sb_Scope_of_Social_Bar, sb_Allow_Anonymous_Post);
    }
    private void Post_Serving(object sender, ServingEventArgs e)
    {
        post = (Post)sender;
        CreateFriendConnectBar(e);
    }

I removed his code where he is checking whether it is a post page or stuffs related to posts which he is checking in his first few lines and created a method called CreateFriendConnectBar(ServingEventArgs e) which i call from the Post_Serving event basically i am not checking that is the post null or something else, this will run in every case.

The important thing which you have to do other then what is stated is instead of this line

string sb_Scope_of_Social_Bar = "PAGE";

 

just replace “PAGE” with “SITE”, then just follow the instruction given on his blog to complete the steps.

string sb_Scope_of_Social_Bar = "SITE";

 

One more thing which most of you will forget is that consider a situation wherein from your previous blogspot blog your were having 2000 followers then you definitely would not want to lose your followers by just going and creating a absolutely new account for the new domain hosting.

So the solution for this is just go to your Google Friend Connect account and remap the url or site url field to your new website on the custom domain.

 

 

 

 

Also as a quick tip make sure your are having rpc_relay  and canvas files in your website root folder.

Submit this story to DotNetKicks

del.icio.usSave Total0 users

7 comments:

Monica Davis said...

Thanks that was very helpful.

I was trying somewhat similar and your tip helped me a lot. I have also browse your silverlight articles and they are informative too.

cheap windshield granada hills said...

Admiring the time and effort you put into your blog and detailed information you offer! I will bookmark your blog and have my children check up here often.
by: Mary Mea

replicapot.com said...

Well, I have been reading your blog posts daily and the reason I come on your blog frequently is its compelling content… Regards…



replicapot.com

ED said...

Interesting article indeed!

Cleveland Web Designers said...

Nice Post :)

outdoor bar stools said...

It’s really great post, nice blog..I am really looking forward to your next post. very good post informative content,
Thanks for sharing!

Legal Debt Solutions said...

Your post is really nice, now i knew how we can add Google Friend to Blogengine.net Blog, Thanks for sharing it here.

Post a Comment