Regarding: *require_once './includes/bootstrap.inc'; drupal_bootstrap(DRUPAL_BOOTSTRAP_CONFIGURATION); // Choose the minimum bootstrap level necessary for your module.*
Thanks for the below information. If all I want to do is just send an ajax call to a drupal url which points to a callback that only has a return statement in it (originally I returned the contents of 2 session variables but I will eliminate that if it causes additional overhead). What would the minumum parameter for drupal_bootstrap needed for the scenario listed above? According to the documentation it appears to be DRUPAL_BOOTSTRAP_CONFIGURATION. Am I correct that I should use DRUPAL_BOOTSTRAP_CONFIGURATION as the parameter? Thanks, John Parameters $phase A constant. Allowed values are: DRUPAL_BOOTSTRAP_CONFIGURATION: initialize configuration. DRUPAL_BOOTSTRAP_EARLY_PAGE_CACHE: try to call a non-database cache fetch routine. DRUPAL_BOOTSTRAP_DATABASE: initialize database layer. DRUPAL_BOOTSTRAP_ACCESS: identify and reject banned hosts. DRUPAL_BOOTSTRAP_SESSION: initialize session handling. DRUPAL_BOOTSTRAP_LATE_PAGE_CACHE: load bootstrap.inc<http://api.drupal.org/api/drupal/includes--bootstrap.inc/6>and module.inc <http://api.drupal.org/api/drupal/includes--module.inc/6>, start the variable system and try to serve a page from the cache. DRUPAL_BOOTSTRAP_LANGUAGE: identify the language used on the page. DRUPAL_BOOTSTRAP_PATH: set $_GET['q'] to Drupal path of request. DRUPAL_BOOTSTRAP_FULL: Drupal is fully loaded, validate and fix input data. On Sun, Feb 6, 2011 at 12:21 PM, Greg Knaddison < [email protected]> wrote: > Drupal's bootstrap takes something like 50% of the total page > processing time on a typical page. You are still paying for that > overhead even though you don't need it. > > See > http://api.drupal.org/api/drupal/includes--bootstrap.inc/function/drupal_bootstrap/6 > and look at something like the chatroom module's lightweight bootstrap > code: > > > http://drupalcode.org/viewvc/drupal/contributions/modules/chatroom/chatroomread.php?revision=1.29.4.19&view=markup > > In particular: > > require_once './includes/bootstrap.inc'; > drupal_bootstrap(DRUPAL_BOOTSTRAP_CONFIGURATION); > // Choose the minimum bootstrap level necessary for your module. > > // Put your code here. > // See performance skyrocket. > // Rejoice. > > Regards, > Greg > > On Sun, Feb 6, 2011 at 10:15 AM, John Mitchell <[email protected]> > wrote: > > Any reason why having a javascript timer fire every 2.5 second for an > ajax > > request to my own callback(listed below) that all it does is return the > > contents of 2 _session variables would take up so much resources? > > > > John > > > > function refreshcarttimer() { > > print($_SESSION['num_items'] . ',' . $_SESSION['uc_price']); > > return; > > } > > > > /** > > * Implementation of hook_menu(). > > */ > > > > function product_type_menu() { > > $items = array(); > > > > $items['cart/refreshcarttimer'] = array( > > 'title' => 'Refresh Shopping Cart', > > 'description' => 'Refresh Shopping Cart', > > 'page callback' => 'refreshcarttimer', > > 'access callback' => TRUE, > > 'type' => MENU_CALLBACK, > > ); > > return $items; > > } > > > > On Sun, Feb 6, 2011 at 2:10 AM, John Mitchell <[email protected]> > > wrote: > >> > >> I have a javascript timer set to fire every 2.5 seconds so that I can > set > >> the current values for the items and total for the shopping cart > summary. I > >> would like to be able to get these values from client side cookies or > >> javascript global variables so that I don't have to make an ajax call to > the > >> server but I have found that the DOM elements are not accessible within > the > >> javascript function unless I run an ajax request to a page (listed > below) > >> and after it returns then the DOM elements are accessible (i.e. > >> $(".num-items").html(numItems);) and now I can update them. Having > these > >> ajax requests run every 2.5 seconds for every client will not scale. > >> > >> How can I make Drupal DOM elements accessible within a javascript > function > >> without having to do an ajax request to a page? > >> > >> Thanks, > >> > >> John > >> > >> setInterval('updateShoppingCartInfo()', 2500); > >> > >> function updateShoppingCartInfo(){ > >> var xmlHttpReq = new XMLHttpRequest(); > >> var url = 'https://' + document.domain + > '/cart/refreshcarttimer'; > >> xmlHttpReq.open('post', url, true); > >> xmlHttpReq.onreadystatechange = function() { > >> if (xmlHttpReq.readyState != 4) { > >> return; > >> } > >> else { > >> var responseText = xmlHttpReq.responseText; > >> var numItems = > >> responseText.substr(0,responseText.indexOf(",")); > >> var ucPrice = > >> responseText.substr(responseText.indexOf(",")+1); > >> $(".num-items").html(numItems); > >> $(".uc-price").html(ucPrice); > >> } > >> } > >> xmlHttpReq.send(null); > >> } > >> > >> > >> -- > >> John J. Mitchell > > > > > > > > -- > > John J. Mitchell > > > > > > -- > Greg Knaddison | 720-310-5623 | http://growingventuresolutions.com > http://masteringdrupal.com - Videos and Tutorials > -- John J. Mitchell
