I'm specifically seeing this when I try to use cpn with the webform module.

The webform module allows a node to be created that accepts fields of a form. Upon submission, it normally redirects to a new page of the form /node/XX/done. Though I have cpn enabled for webforms, and cpn comes up for the node with the form, it does not come up for the "thanks for submitting" node.

Comments

damienmckenna’s picture

Title: cpn doesn't act on node's related nodes » Make CPN code load on all Webform pages

To explain why this happens - the "thanks for submitting" page isn't actually a node and doesn't trigger hook_node_view for the Webform node. That said, it shouldn't be too hard to do, though it would be best as an option that could be controlled - not every site will want this.

damienmckenna’s picture

Version: 7.x-1.4 » 7.x-1.x-dev
Category: bug » feature

This is a feature request.

damienmckenna’s picture

Title: Make CPN code load on all Webform pages » Option to make CPN code load on all Webform pages

Clarifying the title further.

Kaz de Groot’s picture

There is probably a nicer way to do this (with an option, something that also handles node specific confirmation templates, etc) but this seems to do the trick for me:

function cpn_process_webform_confirmation(&$vars) {
  cpn_node_view($vars['node'], 'full', $GLOBALS['language']->language);
  $attached = $vars['node']->content['#attached'];

  foreach(array('css', 'js') as $l) {
    if (isset($attached[$l]) and is_array($attached[$l])) {
      foreach ($attached[$l] as $k => $v) {
        if (substr($k, 0, 4) == 'cpn_') {
          call_user_func('drupal_add_' . $l, $v['data'], $v);
        }
      }
    }
  }
}