WordPress plugin: Frameable

This plugin is designed to make individual pages of a site frameable. This can be used to enable cut and paste quoting of individual posts or cut and paste (X)HTML only syndication of a blog or blog category.

Edit:I no longer use this plugin, and it is now far better to do this using RSS, so do not use this plugin unless you particularly want to use a frame or an iframe (there are good reasons for doing that).

You can download the plugin and a frameable theme from:
http://pietersz.co.uk/downloads/frameable.zip

Functionality and basic usage

The plugin works by switching themes if a particular query string is appended to the URI (this is the same functionality as Ryan Boren’s theme switcher). By default it uses a theme called Frameable (included in the download). It also adds target=”_top” to links from the post content, so links lead back to the unframed site in the top level window. Adding target=”_top” in the post title needs to be done in the theme (see included Frameable theme for example).

It also provides a function to use on the pages you wish to make frameable. link_to_frameable(link text, ‘inline|external’) Typical usage would be:

echo link_to_frameable(‘Click here for frameable version’, ‘inline’);

This will return a link directly to the frameable version of the page.

Advanced usage

More elaborate usage is possible by setting up a special page (in the WordPress static page sense of the word) on which the (X)HTML to cut and paste is given. For examples of this take a look at this site and click on “clip this” or this site and click on “quote this”. This is how the examples above were generated.

In order to do this you need:

  1. call link_to_frameable with the second a parameter ‘external’. In fact you could simply omit it as this is the default behaviour.
  2. Create a page that uses the functions described below to generate the HTML you want. You will need to use a special page template or a PHP execution plugin.
  3. The page you use for this must either be a top level (no parent page) with the page slug “frameable”, or you need to edit the plugin to to give it the page URL

The two functions provided for this are:

  • frameable_return_uri(); has a single parameter. Its value can be ‘framed’ (the default) which returns the URL of the framed version of the frameable page or ‘original’ which returns the URL of the standard version.
  • frameable_return_title(); no parameters, returns the title of the page you are framing.

Both these functions should be used only on the page which generates the (X)HTML. This page should never be linked to directly as link_to_frameable(‘external’) will link to it with a query string containing the URI of the page you want to frame.

An example of the usage, taken from the link generation page on the Money Terms site.

<iframe src=”<?php echo frameable_return_uri()?>” style=”width:100%”><a href=”<?php echo frameable_return_uri(‘original’);?>”><?php echo(frameable_return_title());?></a></iframe></textarea>

This creates the HTML needed to call show the framed page in an inline frame, and to degrade gracefully to a link to the page instead in a browser that does not understand inline frames.