Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Blog Module /

Discuss the Blog Module.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Add To Any


Reply


1360 Views

Avatar
cbolt

Community Member, 6 Posts

3 September 2009 at 7:45pm

Hi

Just knocked this up for a client's site and thought someone else out there might like it, perhaps want to improve it.

Code for adding an "Add To Any" button on your blog.

See what it does and looks like here:
www.addtoany.com

Add this to your BlogEntry class (not the controller) in BlogEntry.php

   /* Chris Bolt added this to display an AddToAny button in templates. To display use $AddToAny */
   function AddToAny () {
      
      return '<a class="a2a_dd" href="http://www.addtoany.com/share_save?linkname='.urlencode(htmlspecialchars($this->Title)).'&amp;linkurl='.htmlspecialchars(urlencode(Director::absoluteURL(false))).'"><img src="http://static.addtoany.com/buttons/share_save_171_16.png" width="171" height="16" border="0" alt="Share/Save/Bookmark"/></a><script type="text/javascript">a2a_linkname="'.addslashes($this->Title).'";a2a_linkurl="'.addslashes(urlencode(Director::absoluteURL(false))).'";a2a_onclick=1;a2a_show_title=1;</script><script type="text/javascript" src="http://static.addtoany.com/menu/page.js"></script>';
      
   }

Then in your BlogEntry template (BlogEntry.ss) simply put $AddToAny
I put it just below the blog entry.

have fun.