Today countdown timer is not working when it was working yesterday. I have tracked down the problem and it looks to be in your implementation of drupal_add_js()
Instead of adding the js in a separate file you have used hook_menu to add a virtual file, this would normally work, but today it doesn't.
Here is where the problem shows itself
<script type="text/javascript" src="/drupal-6.0/misc/jquery.js?q"></script>
<script type="text/javascript" src="/drupal-6.0/misc/drupal.js?q"></script>
<script type="text/javascript" src="/drupal-6.0/countdowntimer/timerjs?q"></script>
<script type="text/javascript" src="/drupal-6.0/sites/all/modules/dhtml_menu/dhtml_menu.js?q"></script>
<script type="text/javascript">jQuery.extend(Drupal.settings, { "basePath": "/drupal-6.0/", "dhtmlMenu": { "useEffects": 0 } });</script>
Notice the query string at the end of the 'src' tag. According to the documentation for drupal_get_js() this query string is here 'to gain control over browser-caching'. The problem we run into today is the query string is '?q', and the menu api thinks that the page it is looking for is '/drupal-6.0/' instead of '/drupal-6.0/countdowntimer/timerjs'.
This solution changes the query string to time() by telling drupal_add_js() not to cache the javascript.
Another solution would be to add the js in another file, but then we would need to figure out how to get the variables into the script, which is beyond my knowledge of javascript. This patch implements the first solution by telling drupal_add_js not to cache the js file.
| Comment | File | Size | Author |
|---|---|---|---|
| jscountdowntimer-cache_query_string.patch | 716 bytes | jrglasgow |
Comments
Comment #1
jvandervort commentedExcellent write up, thanks. patch committed.
Comment #2
jrglasgow commented