ShareThis Extension

From Jimbojw.com

Jump to: navigation, search
Screenshot
Screenshot

The ShareThis Extension is a MediaWiki extension for adding links to popular social bookmarking and news sites. The links can either be included directly in articles, or presented as a portlet in the sidebar.

It is released under The MIT License.

Contents

Compatibility

This extension requires:

  • MediaWiki 1.6.x, 1.8.x, 1.9.x, and higher
  • PHP 4.x, 5.x and higer

Installation

  1. Download ShareThis, and be sure to rename the downloaded file to ShareThis.php.
  2. Drop the downloaded script in $IP/extensions
    Note: $IP is your MediaWiki install dir.
  3. Download sharethis-icons.zip
  4. Extract the archive contents into $IP/skins/common/images (it will create a directory called 'sharethis')
  5. Enable the extension by adding this line to your LocalSettings.php:
    require_once('extensions/ShareThis.php');

Usage

Once installed, you can add links to the social bookmarking or news sites to any page.

To do so, simply add the following to the the article where the links are to appear:

<sharethis />

Here's an example:

Configuration

All steps listed in the following sections are optional.

Displaying the Sidebar

If you'd like the "Share This" sidebar to be displayed, simply add the following to your LocalSettings.php:

$wgShowShareThisSidebar = true;

Note: This works by hooking into 'MonoBookTemplateToolboxEnd'. If you're using a skin which doesn't call this hook, then the above will not work.

Styling the Sidebar

If you'd like to remove the bullets from the items in the ShareThis sidebar:

  1. When logged in as a user with sysop privileges, open "MediaWiki:Common.css"
  2. Add the following:
#p-sharethis li {
  list-style-type: none;
  list-style-image: none;
}
#p-sharethis ul {
  margin-left: 0.5em;
}

Changing the Sidebar Header

The sidebar header is controlled by a system message so it is easy to change - either for personal preference, or for internationalization purposes.

To modify the header text:

  1. As a user with sysop privileges, open the article [[MediaWiki:share-this-sidebar-header]]
  2. Replace the default text (Share This!) with header-text of your choosing.
  3. Save the article.

Note that due to page caching, this change will not immediately be reflected on all pages. See the MediaWiki FAQ Page for information on purging the cache.

Adding Custom Links

If a particular social bookmarking or news site is not listed by default, you can add it!

  1. Determine the name of the chosen service (for the purposes of this example, we'll use 'PopularService').
  2. Acquire an icon to use for the service - a good place to get one is the site's 'favicon.ico' file.
  3. Format the icon as PNG and name it the same as the service name (for example 'PopularService.png').
  4. Copy the PNG file to $IP/skins/common/images/sharethis
  5. Determine the URL for adding links to the chosen service. There will should be fields for the 'title' of the link and the 'url'.
  6. Replace the 'url' portion of the link with '$1'
  7. Replace the 'title' portion of the link with '$2'
  8. Add a new item to the $wgShareThisSiteList array in your LocalSettings.php file like so:
$wgShareThisSiteList['PopularService'] = 'http://some.site/path/to/script?url=$1&amp;title=$2';

For example, here's how you would add a new entry for submitting links to dzone.com.

$wgShareThisSiteList['dzone'] = 'http://www.dzone.com/links/add.html?url=$1&amp;title=$2&amp;description=$2';

Important: This must come after the require_once() call that pulls in the extension (as described in #Installation).

Removing Unwanted Links

If a particular social bookmarking or news site is on the list by default, but you don't want it, you can remove it!

  1. Determine the name of the service to remove (for the purposes of this example, we'll use 'PopularService').
  2. Remove the item from the $wgShareThisSiteList array in your LocalSettings.php file like so:
unset($wgShareThisSiteList['PopularService']);

For example, here's how you would remove the entry for digg.com:

unset($wgShareThisSiteList['digg']);

Important: This must come after the require_once() call that pulls in the extension (as described in #Installation).

Comments

Leave a comment
Sorry, comments are disabled.

or, read what others have said ...