diff --git a/simplemenu.js b/simplemenu.js
index fed20cf4..9b834807 100644
--- a/simplemenu.js
+++ b/simplemenu.js
@@ -3,9 +3,22 @@
$(document).ready(function() {
// get the Drupal basepath
var basePath = Drupal.settings.simplemenu.basePath;
-
- // insert extra
so menu doesn't overlap theme
- $('
').prependTo('body');
+ // get the element to add the menu to
+ var element = Drupal.settings.simplemenu.element;
+ var menu = '';
+
+ switch (Drupal.settings.simplemenu.placement) {
+ case 'prepend':
+ $(menu).prependTo(element);
+ break;
+ case 'append':
+ $(menu).appendTo(element);
+ break;
+ case 'replace':
+ $(element).html(menu);
+ break;
+ }
+
$('body').css('margin-top', '23px');
// Drupal menu callback
diff --git a/simplemenu.module b/simplemenu.module
index 49c874b6..a05671f8 100644
--- a/simplemenu.module
+++ b/simplemenu.module
@@ -33,11 +33,17 @@ function simplemenu_menu($may_cache) {
// We put this in !$may_cache so it's only added once per request
elseif (user_access('view simplemenu')) {
$path = drupal_get_path('module', 'simplemenu');
- drupal_add_css($path .'/simplemenu.css');
-
- // pass in base path to the JS file
- // url() handles appending ?q= but in this case, we need to pass in the variable so the menus work when mod_rewrite is off
- drupal_add_js(array('simplemenu' => array('basePath' => base_path() . (variable_get('clean_url', 0) ? '' : '?q='))), 'setting');
+ drupal_add_css($path .'/simplemenu.css');
+
+ $settings = array(
+ // pass in base path to the JS file
+ // url() handles appending ?q= but in this case, we need to pass in the variable so the menus work when mod_rewrite is off
+ 'basePath' => base_path() . (variable_get('clean_url', 0) ? '' : '?q='),
+ 'placement' => variable_get('simplemenu_element_method', 'prepend'),
+ 'element' => variable_get('simplemenu_element', 'body')
+ );
+
+ drupal_add_js(array('simplemenu' => $settings), 'setting');
drupal_add_js($path .'/simplemenu.js');
}
@@ -68,6 +74,30 @@ function simplemenu_admin_settings() {
'#title' => t('Add devel module links'),
'#default_value' => variable_get('simplemenu_devel', 0),
'#description' => t('Add devel module links for those users that can access the devel module.')
+ );
+
+ $form['default_menu']['advanced'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Advanced settings'),
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE
+ );
+
+ $form['default_menu']['advanced']['simplemenu_element'] = array(
+ '#type' => 'textfield',
+ '#title' => t('CSS selector to attach menu to'),
+ '#default_value' => variable_get('simplemenu_element', 'body'),
+ '#description' => t('A valid CSS selector to attach the menu to. Example: body, #primary, div.my-class'),
+ '#required' => TRUE
+ );
+
+ $form['default_menu']['advanced']['simplemenu_element_method'] = array(
+ '#type' => 'radios',
+ '#title' => 'Attach method',
+ '#options' => drupal_map_assoc(array('prepend', 'append', 'replace')),
+ '#default_value' => variable_get('simplemenu_element_method', 'prepend'),
+ '#description' => t('Choose how the menu should be attached to the above selector.'),
+ '#required' => TRUE
);
return system_settings_form($form);