I have "load ads last" checked in hopes of eventually being able to refresh ads when users click prev/next in a slideshow. I'm getting this error in chrome:

Uncaught TypeError: Cannot read property '1' of null on line 87 of dart.js. Which is in this function:

 * If there are tags in the loadLastTags, then load them where they belong.
Drupal.behaviors.DART = {
  attach: function(context) {
    if (typeof(Drupal.DART.settings.loadLastTags) == 'object') {
      $('.dart-tag:visible').not('.dart-processed').each(function() {
        var regex = /dart-name-(\w+)$/;
        var result = regex.exec($(this).attr('class'));
        var scriptTag = Drupal.DART.tag(Drupal.DART.settings.loadLastTags[result[1]]);
Uncaught TypeError: Cannot read property '1' of null

I've stepped through it with breakpoints. The $('.dart-tag:visible') does find the div elements, but regex.exec() returns null, which causes the next line to fail.

Here is an example of a block containing an ad:

<div class="block block-dart contextual-links-region block-dart-tag-square-above-fold block-dart-dart-tag-square-above-fold even block-without-title" id="block-dart-dart-tag-square-above-fold">
  <div class="block-inner clearfix">
            <div class="contextual-links-wrapper contextual-links-processed"><a class="contextual-links-trigger" href="#">Configure</a><ul class="contextual-links element-hidden"><li class="block-configure first last"><a href="/admin/structure/block/manage/dart/dart-tag-square_above_fold/configure?destination=node/9730">Configure block</a></li></ul></div>    
    <div class="content clearfix">
<div class="dart-tag">
            <script type="text/javascript">Drupal.DART.settings.loadLastTags['square_above_fold'] = '{"machinename":"square_above_fold","name":"Square Above fold","pos":"sidebar","sz":"300x250,300x600","active":"1","block":"1","settings":{"overrides":{"site":"","zone":"","slug":""},"options":{"scriptless":0,"method":"adj","include_terms":0},"key_vals":[],"scheduler":[]},"table":"dart_tags","type":"Normal","export_type":1,"key_vals":{"pos":[{"val":"sidebar","eval":false}],"sz":[{"val":"300x250,300x600","eval":false}],"site":[{"val":"lcl","eval":0}],"env":[{"val":"newdev","eval":false}],"tile":[{"val":"tile++","eval":true}],"ord":[{"val":"ord","eval":true}]},"prefix":"lcl","site":"mdp.com","zone":"","slug":"","network_id":"","noscript":{"src":"http:\/\/ad.doubleclick.net\/ad\/lcl.mdp.com\/;pos=sidebar;sz=300x250,300x600;site=lcl;env=newdev;tile=13;ord=1353291175?","href":"http:\/\/ad.doubleclick.net\/jump\/lcl.mdp.com\/;pos=sidebar;sz=300x250,300x600;site=lcl;env=newdev;tile=13;ord=1353291175?"}}';</script>
<a id="context-block-dart-dart-tag-square_above_fold" class="context-block editable edit-sidebar"></a>    </div>

Does anybody have any ideas that might help me track this down? Thanks!


scottatdrake’s picture

Oh! Just realized that class "dart-name-" appears nowhere in the page source. That certainly has something to do with it. But why?

I'm using the blocks generated by the DART module and placing them in various places with both Context and Panels.

scottatdrake’s picture

I got this working but had to hack (revert?) the way classes are passed in template_preprocess_dart_tag(), based on the conversation around this post.

@@ -564,7 +565,7 @@
 function template_preprocess_dart_tag(&$variables) {
   $tag = $variables['tag'];
-  $variables['attributes_array']['class'] = 'dart-tag dart-name-' . $tag->machinename;
+  $variables['classes_array'][] = 'dart-tag dart-name-' . $tag->machinename;
   $variables['json_tag'] = drupal_json_encode($tag);
   $variables['load_last']   = variable_get('dart_load_last', '0');
bleen’s picture

Can you please upload a patch file to be evaluated ... thanks!

scottatdrake’s picture

661 bytes

Patch attached. Formatted correctly?

bleen’s picture

Status:Active» Needs work
535 bytes
53.04 KB

Almost correct ... when you submit a patch for a contrib module, you should create it from the root of the contrib modules folder, not the root of your drupal site.

That said, I gave your suggestion a try and it causes an error when I use it on a vanilla D7 install with a simple tag displayed in the second sidebar:

The patch I tried is attached.

bblake’s picture

Status:Needs work» Needs review
536 bytes

Previous patch left out the [] after ['classes_array'].

Corrected patch attached.

bleen’s picture

Status:Needs review» Fixed
1.78 KB

I committed this attached patch ... should solve this once and for all

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.