Community Documentation

Facebook-style Statuses: Share Page

Last updated April 22, 2011. Created by IceCreamYou on April 22, 2011.
Log in to edit this page.

Facebook-style Statuses provides a Share page to quickly and easily post status updates. This page is at http://example.com/statuses/share and allows people browsing other sites to easily post links to your site via their status. The text that will appear in the status goes in the 's' query string in the URL. For example, the URL http://example.com/statuses/share?s=is%20happy would pre-fill (but not submit) the status update textfield with the text "is happy."

Other Parameters

In addition to s, you can also add other parameters to the query to change the appearance of the form that appears on the page. For example, you can set rsid=[STATUS ID] to make text above the form appear that says "In response to [STATUS TEXT]." There is also the sid parameter, which takes a status ID and pre-fills the status form with text determined from the re-post template in the module's settings (ignoring the s and rsid parameters). If you set the destination parameter, a "Back" link will appear beneath the form to allow users to return to where they were before posting the status.

All of these parameters work on any other page that has a status update form as well. (The exception is the 's' parameter, since other modules might use it; use 'share-status' instead.)

Bookmarklet

This JavaScript code, when executed as a bookmark, will allow people to post the page they're viewing to their status on your site without needing a link on the site they're viewing. Note that some browsers (most importantly Internet Explorer) will warn users before saving a JavaScript bookmark. In some browsers you can put this code in the "href" property of a link and users can simply click-and-drag to their Bookmark/Favorites list; in others they will need to copy-and-paste it.

Be sure to replace example.com with your website URL.

javascript:void(location.href='http://example.com/statuses/share?s='+escape(document.title)+' '+escape(location.href)+' '+escape(window.getSelection()))

If you're having problems in some browsers, try replacing the space with the URL-encoded space symbol, %20.

In Depth

Let's look at the parts of this so you can change it if you want:

This tells the browser to open a new window with your desired URL in it.

location.href='http://example.com/statuses/share?s='

This safely inserts the title of the current page into the status.

escape(document.title)

This safely inserts the URL of the current page into the status.

escape(location.href)

This safely inserts any text that the user had selected in the current page into the status. Does not work in Internet Explorer.

escape(window.getSelection())

If you find that your bookmarklet consistently produces text that is too long to fit in the status update textfield, you can increase the amount of characters that is allowed. If you increase the maximum status length beyond 140 characters and you have Twitter module integration enabled, status updates that are too long to fit in a tweet will be automatically shortened.

Page status

No known problems

Log in to edit this page

About this page

Drupal version
Drupal 6.x, Drupal 7.x
Audience
Developers and coders, Site administrators

Site Building Guide

Drupal’s online documentation is © 2000-2012 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.