SexyBookmarks for CakePHP with Mootools
Recognize the beautiful bookmark tool on this bottom of article? That is SexyBookmarks! we can get it on http://www.sexybookmarks.net for free. It's quite straight forward to use on wordpress as they provide it in a wordpress plugin. Some another platforms are also guided on "platforms" section on sexybookmarks website, but for CakePHP here is my way to accomplish it.
My method is so simple, this bookmark tool will be included on the pages as a cakePHP element. I'm a big fan of mootools JavaScript framework so I'll take the advantage from it, as I also used it for the another tasks for this personal site.
First step is go to http://www.sexybookmarks.net to download the package, it's OK to donwload as a wordpress plugin, we just need the CSS and images, they are :
- style.css (to avoid naming confusion, I renamed this file to sexystyle.css)
- sexy-trans.png
- and sexy-sprite.png
- Create a folder "images" under app/webroot/ and placed those pngs inside it and put sexystyle.css inside app/webroot/css.
- Get this sexybookmarks.ctp and put inside app/view/elements/
- Create a js file on app/webroot/js/ named it as sexy-bookmarks-moo.js
This js controlled the variables send to the sharer and handle the opening animation.
Show Plain Text
- window.addEvent('domready', function() {
- var sexyBaseHeight=$$('.sexy-bookmarks').getStyle('height');
- var sexyFullHeight=$$('.sexy-bookmarks ul.socials').getStyle('height');
- var url = encodeURIComponent(window.location.href), desc = '';
- //catch first paragraph in content div as description text.
- //change it as your div name may different.
- var desc = $$("#content p")[0].get('html');
- var title = document.title;
- $$('div.sexy-bookmarks').addEvent('mouseover', function(){
- this.tween('height',sexyFullHeight);
- });
- $$('div.sexy-bookmarks').addEvent('mouseout', function(){
- this.tween('height',sexyBaseHeight);
- });
- $$('.sexy-bookmarks a.external').addEvent('click',function() {
- this.set("target", "_blank");
- switch(this.getParent().get('class')) {
- case 'sexy-twittley':
- this.set('href',this.get('href')+'?title=' + title + '&url=' + url + '&desc=' + desc + '&pcat=Internet&tags=');
- break;
- case 'sexy-digg':
- this.set('href',this.get('href')+'?phase=2&title=' + title + '&url=' + url + '&desc=' + desc);
- break;
- case 'sexy-twitter':
- this.set('href',this.get('href')+'?status=' + title + '+-+' + url);
- break;
- case 'sexy-scriptstyle':
- this.set('href',this.get('href')+'?title=' + title + '&url=' + url);
- break;
- case 'sexy-reddit':
- this.set('href',this.get('href')+'?title=' + title + '&url=' + url);
- break;
- case 'sexy-delicious':
- this.set('href',this.get('href')+'?title=' + title + '&url=' + url);
- break;
- case 'sexy-stumbleupon':
- this.set('href',this.get('href')+'?title=' + title + '&url=' + url);
- break;
- case 'sexy-mixx':
- this.set('href',this.get('href')+'?title=' + title + '&page_url=' + url + '&desc=' + desc);
- break;
- case 'sexy-technorati':
- this.set('href',this.get('href')+'?add=' + url);
- break;
- case 'sexy-bthislist':
- this.set('href',this.get('href')+'?Action=Bthis/addblink.php&Title=' + title + '&Url=' + url);
- break;
- case 'sexy-diigo':
- this.set('href',this.get('href')+'?title=' + title + '&url=' + url + '&desc=' + desc);
- break;
- case 'sexy-yahoobuzz':
- this.set('href',this.get('href')+'?submitHeadline=' + title + '&submitUrl=' + url + '&submitSummary=' + desc + '&submitCategory=science&submitAssetType=text');
- break;
- case 'sexy-myspace':
- this.set('href',this.get('href')+'?t=' + title + '&u=' + url);
- break;
- case 'sexy-facebook':
- this.set('href',this.get('href')+'?t=' + title + '&u=' + url);
- break;
- case 'sexy-designfloat':
- this.set('href',this.get('href')+'?title=' + title + '&url=' + url);
- break;
- case 'sexy-devmarks':
- this.set('href',this.get('href')+'?posttitle=' + title + '&posturl=' + url + '&posttext=' + desc);
- break;
- case 'sexy-newsvine':
- this.set('href',this.get('href')+'?h=' + title + '&u=' + url);
- break;
- case 'sexy-google':
- this.set('href',this.get('href')+'?op=add&title=' + title + '&bkmk=' + url);
- break;
- }
- });
- });
Don't forget to include mootools core library before $scripts_for_layout; on our template layout. Get into the desired section you want to display sexybookmakrs and load the element using this snippet:
Show Plain Text
- echo $this->element('sexybookmarks');
See the result.... so Sexy!