Skip to content
Snippets Groups Projects
Commit e85f9e0e authored by Frank Anderson's avatar Frank Anderson
Browse files

Added admin ui menu callback and setting form.

parent 74dcf61f
No related branches found
No related tags found
No related merge requests found
<?php
function googleanalytics_admin_settings($form, &$form_state) {
$config = config('googleanalytics.settings');
$form['trackingId'] = array(
'#type' => 'textfield',
'#title' => t('Google Analytics Tracking ID'),
'#default_value' => $config->get('trackingId'),
'#description' => t('Enter Your Google Analytics Tracking ID. Format should be UA-12345678-9'),
);
return system_config_form($form, $form_state);
}
function googleanalytics_admin_settings_submit($form, $form_state) {
config('googleanalytics.settings')
->set('trackingId', $form_state['values']['trackingId'])
->save();
}
......@@ -10,11 +10,8 @@
*/
function googleanalytics_page_build(&$page) {
// note : to keep api codes out of the repo, add config files to .gitignore
$config = config('googleanalytics.settings');
$googleanalytics_tracking_id = $config->get('trackingId');
// dpm($config);
// dpm($googleanalytics_tracking_id);
// Seems like the attached isn't working, possibly because this is in-line code
// $page['#attached']['js'][$script] = array('every_page' => TRUE);
......@@ -22,7 +19,22 @@ function googleanalytics_page_build(&$page) {
drupal_add_js(_googleanalytics_get_code($googleanalytics_tracking_id),
array('type' => 'inline', 'scope' => 'footer', 'weight' => 5)
);
// dpm($page);
}
/**
* Implements hook_menu().
*/
function googleanalytics_menu() {
$items['admin/config/statistics/googleanalytics'] = array(
'title' => 'Google Analytics Lite settings',
'description' => 'Google Analytics Integration Settings.',
'page callback' => 'drupal_get_form',
'page arguments' => array('googleanalytics_admin_settings'),
'file' => 'googleanalytics.admin.inc',
'access arguments' => array('administer site configuration'),
);
return $items;
}
/*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment