Jump to:

1844 Posts in 1600 Topics by 559 members

Blog Module

SilverStripe Forums » Blog Module » Add To Any

Discuss the Blog Module.

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

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

    Add To Any Link to this post


    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:

    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.

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.