Extension:IframePage

From MediaWiki.org
Jump to navigation Jump to search
MediaWiki extensions manual
Crystal Clear action run.svg
IframePage
Release status: beta
Implementation Special page
Description Allows embedding an iframe into a special page
Author(s) Ike Hecht (tosfostalk)
Latest version 0.2.1 (September 2014)
MediaWiki > 1.19
PHP 5.3+
Database changes No
License GNU General Public License 2.0 or later
Download
Parameters
$wgIframePageSrc, $wgIframePageAllowPath
Translate the IframePage extension if it is available at translatewiki.net
Check usage and version matrix.

The IframePage extension allows embedding an iframe into a special page. The iframe src is set in LocalSettings.php so that it does not pose a security risk. It is useful for embedding functionality from an external site and visually integrating it as if it was contained in the wiki.

Installation[edit]

  • Download and place the file(s) in a directory called IframePage in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php:
    require_once "$IP/extensions/IframePage/IframePage.php";
    $wgIframePageSrc= array( /* REQUIRED! */ );
    
  • Yes Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Configuration parameters[edit]

$wgIframePageSrc
An associative array containing the iframe src. Mandatory.
The key in this array is expected to be a simple string that will be used as the title of a subpage of Special:IframePage. The value should contain the actual iframe src URL.
The key can be omitted. That is because navigating to Special:Iframepage will simply pull the URL contained in the first value in the $wgIframePageSrc array.
$wgIframePageAllowPath
Defaults to false. If set to true, it allows passing a parameter using ?path=.... The path value will be appended to the URL contained in $wgIframePageSrc.

Examples[edit]

These examples are described using YouTube or Vimeo and are just for illustration.

Simple example[edit]

$wgIframePageSrc = array( 'YouTube' => 'https://www.youtube.com/embed/DWef69ItVrU' );

In this case, navigating to Special:Iframepage/YouTube or to Special:Iframepage will display a video with the ID specified in the $wgIframePageSrc array.

Example using a path[edit]

$wgIframePageSrc = array( 'YouTube' => 'https://www.youtube.com/embed/', 'Vimeo' => 'https://player.vimeo.com/video/' );
$wgIframePageAllowPath = true;

In this case, navigating to Special:Iframepage/YouTube or to Special:Iframepage will cause a YouTube error, since no ID was specified. You can send an ID by specifying the path. For example, you can navigate to Special:IframePage/YouTube?path=DWef69ItVrU to see the above video. Or substitute the path with any YouTube video ID.

Alternatively, to see a Vimeo video, navigate to Special:IframePage/Vimeo?path=42683487, substituting the path with any Vimeo ID.

Including on another page[edit]

It is possible to include the IframePage on another page. Use {{Special:IframePage}} when editing the page.

If you need to pass in the url then use pipes the same way you would for other mediawiki templates: {{Special:IframePage|Youtube|path=sYgxTkg2j5Hxoeei/embed}}

Adding rel=nofollow[edit]

To keep search engines from crawling the external websites, as most iframes will be external websites, this can be done a few ways. The recommended option is editing the SpecialIframePage.php and adding to the $html .= Html::element array so the last two lines of the array look like this:
'height' => '100%',
'rel' => 'nofollow'
Note: there must be a comma (,) at the end of the previous "height" array.
The second option is to add disallow: /Special:IframePage to your robots.txt file in the wiki installation directory. This is the less preferable option as the entire page will not show up in the search enginge results rather than the links within the iframe.

See also[edit]