petkivim / embed-google-docs

Embed Google Docs Viewer makes it possible to embed Google Docs Viewer to Joomla articles.
GNU General Public License v3.0
18 stars 12 forks source link

Embed Google Docs Viewer

Embed Google Docs Viewer is a plugin for embedding one or more Google Docs Viewers to Joomla articles. By using Google Docs Viewer it's possible to quickly view documents online without leaving browser. Adding Google Docs Viewer to an article is very simple, just add the url of the document that you want to embed, and that's it! It's also possible to define the size of the document, mode of the reader (preview/edit), border layout and link to the full size document.

Features

Syntax

Example

Replace the "document_url" string with the url of the document that you want to view.

{google_docs}http://www.example.com/docs/document.pdf{/google_docs}

Multilingual features

The language setting can be used with Google Docs Viewer only, and it doesn't work with documents stored in Google Drive.

In the front-end it's possible to use the system language as a Google Docs Viewer language. In multilingual sites this means that it's enough to set the default language to 'system', and the language of the viewer is set according to the language that the user has chosen. For individual docs the default setting can be overridden by using the 'lang' parameter. Setting the system language for individual docs can be done by setting the 'lang' parameter to 'system'

{google_docs}document_url|lang:system{/google_docs}

It's also possible to use translatable strings as link label, e.g. {TRANSLATABLE_STRING}.

Border styles

The default border style can be set in the admin panel, but it can be overridden by using the border_style variable. The following values are supported.

Border color

The default border color can be set in the admin panel, but it can be overridden by using the border_color variable. Border color must be given in hexadecimal format. The default value is "#000000".

Google Docs documents

Supported Google document formats: document, spreadsheet, presentation, form, drawing, file.

If you want to embed a document stored in Google Docs do the following.

  1. Sign in to your Goole Docs account.
  2. Open the document that you want to embed.
  3. Click File -> Publish to the web.
  4. Copy the link from the "Document link" field.
  5. Paste the link between the google_docs tags.

The above steps don't work with forms. To embed a form do the following.

  1. Sign in to your Goole Docs account.
  2. Open the form that you want to embed.
  3. Click Form -> Go to live form.
  4. The form opens in a new tab/window.
  5. Copy the URL from the browser's address bar.
  6. Paste the URL between the google_docs tags.

Google Docs Viewer's mode

It's possible to set the Google Doc Viewer's mode when embedding documents created or stored in Google Docs. The mode can be set to default, preview and edit. The output depends on the type of the document as not all the types support all the modes. The default type for the site can be set in the admin panel and it can overridden by using the mode parameter.

The default mode means that the document is embedded in the way suggested by Google Docs Publish to the web function. Preview means preview mode and edit means edit mode. The output depends on the document type and in many cases default and preview modes produce the same output. If the selected mode is not supported by the document type, the default mode is used.

Base URL

In the admin panel it's possible to define a base URL for the documents, which makes embedding the documents even easier as there's no need to type in the full URL for each document. When the base URL is set, the documents can be embedded by using a relative URL. By default the plugin considers Joomla's install directory's URL as the base URL.

Base url: http://www.example.com/docs/
Full URL of the document: http://www.example.com/docs/document.pdf

{google_docs}document.pdf{/google_docs}

When the base URL is defined it's still possible to embed documents stored in another locations. In this case you just have to use the full URL of the document.

Language codes

The default language can be set in the admin panel, but it can be overridden by using the lang variable. When using the lang variable, the code of the selected language must be given as a parameter. Below there's a list of languages supported by Google Docs Viewer.

NB! The language setting can be used with Google Docs Viewer only, and it doesn't work with documents stored in Google Docs.

Code Language
ar Arabic
eu Basque
bn Bengali
bg Bulgarian
ca Catalan
zh-CN Chinese (simplified)
zh-TW Chinese (traditional)
hr Croatian
cs Czech
da Danish
nl Dutch
en English
en-AU English (Australian)
en-GB English (Great Britain)
fa Farsi
fil Filipino
fi Finnish
fr French
gl Galician
de German
el Greek
gu Gujarati
iw Hebrew
hi Hindi
hu Hungarian
id Indonesian
it Italian
ja Japanese
kn Kannada
ko Korean
lv Latvian
lt Lithuanian
ml Malayalam
mr Marathi
no Norwegian
nn Norwegian Nynorsk
or Oriya
pl Polish
pt Portuguese
pt-BR Portuguese (Brazil)
pt-PT Portuguese (Portugal)
ro Romanian
rm Romansch
ru Russian
sk Slovak
sl Slovenian
sr Serbian
es Spanish
sv Swedish
tl Tagalog
ta Tamil
te Telugu
th Thai
tr Turkish
uk Ukrainian
vi Vietnamese