Regarding:<br><i>require_once './includes/bootstrap.inc';<br>
drupal_bootstrap(DRUPAL_BOOTSTRAP_CONFIGURATION);<br>// Choose the minimum bootstrap level necessary for your module.</i><br><br>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? <br>
According to the documentation it appears to be DRUPAL_BOOTSTRAP_CONFIGURATION.<br>Am I correct that I should use DRUPAL_BOOTSTRAP_CONFIGURATION as the parameter?<br><br>Thanks,<br><br>John<br><h3>Parameters</h3>
<p>
$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 <a href="http://api.drupal.org/api/drupal/includes--bootstrap.inc/6" title="Functions that need to be loaded on every Drupal request." class="local">bootstrap.inc</a> and <a href="http://api.drupal.org/api/drupal/includes--module.inc/6" title="API for loading and interacting with Drupal modules." class="local">module.inc</a>, 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.</p><br><div style="visibility: hidden; display: inline;" id="avg_ls_inline_popup"></div><style type="text/css">#avg_ls_inline_popup { position:absolute; z-index:9999; padding: 0px 0px; margin-left: 0px; margin-top: 0px; width: 240px; overflow: hidden; word-wrap: break-word; color: black; font-size: 10px; text-align: left; line-height: 13px;}</style><br>
<div class="gmail_quote">On Sun, Feb 6, 2011 at 12:21 PM, Greg Knaddison <span dir="ltr"><<a href="mailto:greg@growingventuresolutions.com">greg@growingventuresolutions.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Drupal's bootstrap takes something like 50% of the total page<br>
processing time on a typical page. You are still paying for that<br>
overhead even though you don't need it.<br>
<br>
See <a href="http://api.drupal.org/api/drupal/includes--bootstrap.inc/function/drupal_bootstrap/6" target="_blank">http://api.drupal.org/api/drupal/includes--bootstrap.inc/function/drupal_bootstrap/6</a><br>
and look at something like the chatroom module's lightweight bootstrap<br>
code:<br>
<br>
<a href="http://drupalcode.org/viewvc/drupal/contributions/modules/chatroom/chatroomread.php?revision=1.29.4.19&view=markup" target="_blank">http://drupalcode.org/viewvc/drupal/contributions/modules/chatroom/chatroomread.php?revision=1.29.4.19&view=markup</a><br>
<br>
In particular:<br>
<br>
require_once './includes/bootstrap.inc';<br>
drupal_bootstrap(DRUPAL_BOOTSTRAP_CONFIGURATION);<br>
// Choose the minimum bootstrap level necessary for your module.<br>
<br>
// Put your code here.<br>
// See performance skyrocket.<br>
// Rejoice.<br>
<br>
Regards,<br>
Greg<br>
<div><div></div><div class="h5"><br>
On Sun, Feb 6, 2011 at 10:15 AM, John Mitchell <<a href="mailto:mitchelljj98@gmail.com">mitchelljj98@gmail.com</a>> wrote:<br>
> Any reason why having a javascript timer fire every 2.5 second for an ajax<br>
> request to my own callback(listed below) that all it does is return the<br>
> contents of 2 _session variables would take up so much resources?<br>
><br>
> John<br>
><br>
> function refreshcarttimer() {<br>
> print($_SESSION['num_items'] . ',' . $_SESSION['uc_price']);<br>
> return;<br>
> }<br>
><br>
> /**<br>
> * Implementation of hook_menu().<br>
> */<br>
><br>
> function product_type_menu() {<br>
> $items = array();<br>
><br>
> $items['cart/refreshcarttimer'] = array(<br>
> 'title' => 'Refresh Shopping Cart',<br>
> 'description' => 'Refresh Shopping Cart',<br>
> 'page callback' => 'refreshcarttimer',<br>
> 'access callback' => TRUE,<br>
> 'type' => MENU_CALLBACK,<br>
> );<br>
> return $items;<br>
> }<br>
><br>
> On Sun, Feb 6, 2011 at 2:10 AM, John Mitchell <<a href="mailto:mitchelljj98@gmail.com">mitchelljj98@gmail.com</a>><br>
> wrote:<br>
>><br>
>> I have a javascript timer set to fire every 2.5 seconds so that I can set<br>
>> the current values for the items and total for the shopping cart summary. I<br>
>> would like to be able to get these values from client side cookies or<br>
>> javascript global variables so that I don't have to make an ajax call to the<br>
>> server but I have found that the DOM elements are not accessible within the<br>
>> javascript function unless I run an ajax request to a page (listed below)<br>
>> and after it returns then the DOM elements are accessible (i.e.<br>
>> $(".num-items").html(numItems);) and now I can update them. Having these<br>
>> ajax requests run every 2.5 seconds for every client will not scale.<br>
>><br>
>> How can I make Drupal DOM elements accessible within a javascript function<br>
>> without having to do an ajax request to a page?<br>
>><br>
>> Thanks,<br>
>><br>
>> John<br>
>><br>
>> setInterval('updateShoppingCartInfo()', 2500);<br>
>><br>
>> function updateShoppingCartInfo(){<br>
>> var xmlHttpReq = new XMLHttpRequest();<br>
>> var url = 'https://' + document.domain + '/cart/refreshcarttimer';<br>
>> xmlHttpReq.open('post', url, true);<br>
>> xmlHttpReq.onreadystatechange = function() {<br>
>> if (xmlHttpReq.readyState != 4) {<br>
>> return;<br>
>> }<br>
>> else {<br>
>> var responseText = xmlHttpReq.responseText;<br>
>> var numItems =<br>
>> responseText.substr(0,responseText.indexOf(","));<br>
>> var ucPrice =<br>
>> responseText.substr(responseText.indexOf(",")+1);<br>
>> $(".num-items").html(numItems);<br>
>> $(".uc-price").html(ucPrice);<br>
>> }<br>
>> }<br>
>> xmlHttpReq.send(null);<br>
>> }<br>
>><br>
>><br>
>> --<br>
>> John J. Mitchell<br>
><br>
><br>
><br>
> --<br>
> John J. Mitchell<br>
><br>
<br>
<br>
<br>
</div></div><font color="#888888">--<br>
Greg Knaddison | 720-310-5623 | <a href="http://growingventuresolutions.com" target="_blank">http://growingventuresolutions.com</a><br>
<a href="http://masteringdrupal.com" target="_blank">http://masteringdrupal.com</a> - Videos and Tutorials<br>
</font></blockquote></div><br><br clear="all"><br>-- <br>John J. Mitchell<br>