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;">
</iframe> 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
*
*/
$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($params['local'])) {
$document .= $gCms->config['uploads_url'] . '/' . $file;
} else {
$document .= $file;
}
$document .= '&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'}
Hi Aureli,
you have multiple options here, you could also use a Global Content Block, disable WYSIWYG for that block and paste your iframe code from Google Maps. Another would be a simple UDT, copy your iframe code and then create a UDT with it's ouptut like
echo ' <!--... your iframe code ...--> ';
Excellent, gotta try this.
Pasting iframes into the content of cmsms always gave me problems. I had a page with a googlemap (as like the google docs, the code provided to embed in a webpage is an iFrame) and every time I edited the page, CMSMS would delete the iFrame.
I guess I can modify that code to show the googlemap?
A.