FriendsOfSymfony / friendsofsymfony.github.io

Description of what FriendsOfSymfony (aka FoS) is about.
http://friendsofsymfony.github.io
32 stars 4 forks source link

[RFC] Add a SocialBundle #18

Closed schmittjoh closed 12 years ago

schmittjoh commented 13 years ago

I need some social features for my website like the Facebook's "Like it", Twitter's "Tweet" button, and potentially others.

I haven't found a bundle that does this already, so Is there some interest to make such a bundle part of FOS?

ornicar commented 13 years ago

I assume you envisage a bunch of Twig functions that render the code provided by theses social websites. But no twig function will be able to do social links the way I like them. Let me explain.

Both facebook, twitter and google buttons are iframes. They are heavy, slow to load and slow to render. If you insert them in your page the way they recommend it, it adds signicant time to the global page load time. On every page.

I like to render the page free of these clutters. With empty placeholder <div class="fb_like"></div> elements. Then on the JS side, two seconds after the page is loaded, I add the vendor HTML in the div and asynchronously load its script that transforms it to an iframe.

Everything is JS side so I doubt a bundle will help at all

schmittjoh commented 13 years ago

I agree with you that the recommended way is not really good. The way I'd like to implement it, is by using two separate twig functions one for rendering the html markup, and the other for rendering the javascript.

This way you can place the javascript at the end of the page, and the buttons where you'd like to have them.

Anyway, I think I'll do it in an own bundle for now since the resonance doesn't really look good

lsmith77 commented 13 years ago

Its obviously a frequent feature these days, we have one client that wanted such an integration. I was not on the project when that was build, not sure how well that could be separated into something generic.

At the same time in other projects clients felt that they would prefer just to go with some 3rd party provider and not "waste dev" time on this.

ornicar commented 13 years ago

I'm not fond of php rendering javascript. And I don't like javascript in HTML pages. I have JS files already, I put the social code there.

henrikbjorn commented 13 years ago

Javascript and CSS is not to be auto generated by twig functions. JS and CSS have a place in their own .css or .js files. And if additional logic or variables in needed Coffee and Less are excellent projects whit those capabilities.