Quickly embed Google Docs Viewer in your CMSMS page

This is a quick tip about embeding Google Docs Viewer in your page.
Well the easiest method is to simply visit Google Docs Viewer page and get the iFrame code, but as we have possibility to create a UDT we can make our and clients life easier with a small UDT.

So basicaly the code you get from Google Docs Viewer looks like this:

<iframe src="http://docs.google.com/viewer?url=http%3A%2F%2Flabs.google.com%2Fpapers%2Fbigtable-osdi06.pdf&embedded=true" width="600" height="780" style="border: none;">

Now let's look at the UDT

Go to Extensions » User Defined Tags create new UDT with name gdv_embed and add this code.

 * Creates an iframe for Google Docs Viewer
 * <iframe src="http://docs.google.com/viewer?url=www.something.com&embedded=true" width="600" height="780"></iframe>
 * @params string $params['width'] change the width of iframe
 * @params string $params['height'] change the height of iframe
 * @params string $params['url'] path to a document
 * @params string $params['embed']
 * @params string $params['local'] if true a uploads_url is already included, where url param can be used with /some/folder/somedocument.pdf&nbsp

$gCms = cmsms();
$width = isset($params['width']) ? $params['width'] : '600';
$height = isset($params['height']) ? $params['height'] : '780';
$embed = isset($params['embed']) ? $params['embed'] : 'true';
$local = isset($params['local']);
$file = $params['file'];

$document = '<iframe src="http://docs.google.com/viewer?url=';
if(!empty($local)) {
    $document .=  $gCms->config['uploads_url'] . '/' . $file;
} else {
    $document .= $file;
$document .= '&amp;embedded=' . $embed . '" width="' . $width . '" height="' . $height . '"></iframe>';

return $document;

Now we have a simple tag {gdv_embed} that we can use in Content pages or what actual advantage would be in Modules like for example Uploads, Custom News fields or any other Module that allows us uploading files.
Let's take for example Uploads module, where you would like to embed Google Docs Viewer on Uploads Detail page. Simply go to Uploads module, open a Detail Temaplate that you are using and add {gdv_embed file=$entry->download_url width='500' height='800'}. This way the url of uploaded Document would be linked with our UDT and an iframe created on Detail view.

For a live example you can click on Demo below where UDT was used like {gdv_embed local='1' file='CMSMS_MediaKit2010.pdf' width='740' height='950'}