sharebox

A simple and sexy social network sharing widget
19 followers

Yii Social Share Box

ShareBox allows you to easily share a URL on your Yii powered site with social networking sites.

Requirements

Developed and tested on Yii 1.1.7, should work on all 1.1.x branch.

Install

Extract to your extensions folder.

Alternatively, you can check out from GitHub right in your Git enabled project:

$ git submodule add git@github.com:digitick/yii-sharebox.git extensions/sharebox
$ git submodule init
$ git submodule update

Usage

Include the widget in a view file as follows:

$this->widget('ext.sharebox.EShareBox', array(
    // url to share, required.
    'url' => $this->createAbsoluteUrl('/'),
 
    // A title to describe your link, required.
    // Some services will ignore this value.
    'title'=> 'My Awesome web site !!',
 
    // Size of the icons to display, in pixels.
    // Default is 24px, available sizes : 16, 24, 32, 48.
    //'iconSize' => 32,
 
    // Whether to animate the links.
    // Default is true
    //'animate' => false,
 
   // Social networks to include, excluding all others.
   // The exclude filter is still run.
   //'include' => array('technorati', 'digg'),
 
   // Social networks to exclude from display.
   // By default none are excluded.
   //'exclude' => array('technorati', 'digg'),
 
   // Use your own icons! Note that you will need to have
   // a subfolder of the appropriate icons sizes.
   // ie: /myimages/social/16px /myimages/social/24px ...
   //'iconPath' => '/myimages/social',
 
   // HTML options for the UL element.
   //'ulHtmlOptions' => array('class' => 'myCustomUlClass'),
 
   // HTML options for all the LI elements.
   //'liHtmlOptions' => array('class' => 'myCustomLiClass'),
));

Acknowledgements

ShareBox uses the following resources internally :

Original idea and CSS from Beautiful Social Bookmarking Widget by Harish. The extension uses the CSS only version, no jQuery involved.

16, 24, 32 and 48 px icons from IconDock

Note: the company logos in the icons are copyright of their respective owners.

Resources

Change Log

  • v 1.3 — 2012-09-27 :

    • Add the animate option.
    • CSS fixes and cleanup.
  • v 1.2.2 — 2011-09-27 :

    • Fix XHTML validation errors : url formating and CSS (thanks to Leffe for the CSS improvements).
  • v 1.2.1 — 2011-07-13 :

    • Fix Twitter spelling (thanks to scoob.junior).
  • v 1.2 — 2011-06-09 :

    • Change 'htmlOptions' to 'ulHtmlOptions'. WARNING : this will cause an exception on upgrade. You will need to update your code if you are using this feature !!
    • Use same icons for all sizes.
    • Add 'include' option.
    • Add 'liHtmlOptions'.
  • v 1.1 — 2011-05-24 :

    • Merge improvements contributed by tydeas_dr, many thanks.
    • Allow HTML options for the UL element of the widget, including id and class.
  • v 1.0 — 2011-05-23 : initial release.

Total 3 comments

#5254 report it
Leffe at 2011/09/26 04:32pm
XHTML-validation

This is line 148 in the extension. First, I would add a "}" just before the last double quote to close the CSS block. I don't know if there is a rule that this is not needed for the last CSS-block.

However, the existence of in-line style within the body causes the XHTML-validator to cast an error when this extension is loaded.

echo CHtml::tag('style', array('type' => 'text/css'), 'ul.' . $this->ulHtmlOptions['class'] . " li a {width:{$this->iconSize}px; height {$this->iconSize}px;"

Here is a patch that fixes the problem: yii_sharebox_style_fix.patch The patch was made against version 1.2 of sharebox using hg.

#4428 report it
Junior - df9 at 2011/07/07 10:27pm
very nice - just a little improvement

thanks very much for the extension, very useful

a little change shoud be made in line 70 of EShareBox.php:

name=>'Twitter' instead of name=>'Tweeter'

just a misspelling i think

:)

regards!

#3973 report it
tydeas_dr at 2011/05/24 09:30am
htmlOptions support added

Hello there. Great extension, thanks for sharing. I wanted to add some htmlOptions to the ul created by this extension and I added htmlOptions as an argument. Bellow is the diff with the original 1.0 version as well as the EShareBox.php file I have.

Changes

I Added 2 newparams

/**
      * @var array Html options
      */
     public $htmlOptions = array( );
     /* 
      * @var array Default html options.
      */
     private $defaultHtmlOptions = array(
         "class"=>"way2blogging-social",
         "id"=>"way2blogging-cssanime",
     );

This 2 array merge at the end of EShareBox::init() like:

public function init()
    {
        ...
        $this->htmlOptions = array_merge($this->defaultHtmlOptions, $this->htmlOptions);
}

And this is the changes to the EShareBox::run() function:

//               echo CHtml::tag('style', array('type' => 'text/css'), "ul.way2blogging-social li a {width:{$this->iconSize}px; height:{$this->iconSize}px;");
//               echo CHtml::openTag('ul', array('class' => 'way2blogging-social', 'id' => 'way2blogging-cssanime'));
               echo CHtml::tag('style', array('type' => 'text/css'), "ul.".$this->htmlOptions['class']." li a {width:{$this->iconSize}px; height:{$this->iconSize}px;");
               echo CHtml::openTag('ul', $this->htmlOptions);

Leave a comment

Please to leave your comment.

Create extension