The following use case leads you through the process of appending HTML & javascript to the footer of the Omeka admin panel. In this particular plugin, "Google Translate," a drop-down menu will be appended that will allow users to translate the current view into a different language.
Files You'll Create in this Use Case
- GoogleTranslate/ (folder)
- plugin.ini
- plugin.php
Use Case Steps
1. Create a plugin.ini file with the following text:
[info] name="Google Translate" author="Dave Lester" description="Allows the administrative Omeka theme to be translated using Google Translate." link="http://omeka.org/codex/Plugins/GoogleTranslate" omeka_minimum_version="0.10" omeka_tested_up_to="1.1" version="0.8" tags="translation, google"
2. In this use case. we'll use the plugin hook admin_theme_footer to append text the screen. When the foot(); function is called in the administrative panel, the hook will be run and as a result, run the google_translate_admin_theme_footer' function that's the callback we specify.
The below code is added to the admin theme footer, and implements Google Translate with only a matter of a few lines of code:
<?php // add plugin hooks add_plugin_hook('admin_theme_footer', 'google_translate_admin_theme_footer'); function google_translate_admin_theme_footer() { ?> <div id="google_translate_element"></div><script> function googleTranslateElementInit() { new google.translate.TranslateElement({ pageLanguage: 'en' }, 'google_translate_element'); } </script><script src="http://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script> <?php }