Jump to:

1770 Posts in 495 Topics by 531 members

Blog Module

SilverStripe Forums » Blog Module » Add To Any

Discuss the Blog Module.

Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 926 Views
  • cbolt
    Avatar
    Community Member
    6 Posts

    Add To Any Link to this post

    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.

    926 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.