We have a node type X with a node ref to a SimpleAds node.

We want to display ads related to this refered SimpleAd.

Notice: Undefined index: nid in template_preprocess_views_simpleads() (regel 154 van /.../simpleads/includes/simpleads.theme.inc).

This is due to the fact the views has now a related node and thus more fields available.

      if (isset($data->field_field_ad_category[0])) {
        $tid = $data->field_field_ad_category[0]['raw']['tid'];
        $node = $data->_field_data['nid']['entity'];
        $ads[] = _simpleads_ads_data($node);
      }

A hot fix for us where we grab the first item from the field_data is

        if (isset($data->_field_data['nid'])) {
          $node = $data->_field_data['nid']['entity'];
        }
        else {
          $dummy = $data->_field_data;
          $f = array_shift($dummy);
          $node = $f['entity'];
        }

This is not a patch as I'm not sure how that should look.

Comments

clemens.tolboom’s picture

StatusFileSize
new920 bytes

Attached a patch containing the mentioned hotfix

clemens.tolboom’s picture

Status: Active » Needs review

This needs review.

Note the patch allows for node (with a reference to an Ad) to pick up that add.

It is still not possible to pickup _all_ adds with the category of the referred Ad as the Ad Group is not exposed as a relation.

Status: Needs review » Needs work

The last submitted patch, simpleads-views-refered-ad-1826130-1.patch, failed testing.

clemens.tolboom’s picture

Status: Needs work » Needs review
StatusFileSize
new776 bytes

Fixed (i hope) the wrong paths in the patch.

minnur’s picture

Assigned: Unassigned » minnur

Thanks for the patch, I will review it.

minnur’s picture

Issue summary: View changes
Status: Needs review » Closed (won't fix)